Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Multiply rows with different value according to condition

Hello everyone!!!

 

I am working on a table to calculate sales.

 

The table has date and item sold columns

 

I am looking forward to multiply the "item sold" column with 2 if the date is before April 2020 and multiply "item sold" with 1.5 for April 2020 onwards

 

I tried using IF such that IF Month and Year = January 2020/February 2020/March 2020 times by 2, but I couldn't use my "date" column in my IF calculation. Is there any way to solve this?

 

Thank you! 

1 ACCEPTED SOLUTION

@Anonymous , You are trying a measure I suggested a column

Column =

if(Table[Date] <=date(2020,04,30) ,[Item sold] *2, [item sold]*1.5)

 

measure =

if(max(Table[Date]) <=date(2020,04,30) ,Sum(Table[Item sold]) *2, Sum(Table[item sold])*1.5)

 

day need to be in row context

or try  like

Sumx(values(Table[date]),if(max(Table[Date]) <=date(2020,04,30) ,Sum(Table[Item sold]) *2, Sum(Table[item sold])*1.5))

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , if there is Date tray to use it like this . Create a new column

if(Table[Date] <=date(2020,04,30) ,[Item sold] *2, [item sold]*1.5)

Anonymous
Not applicable

Dear @amitchandak ,

 

I tried using this solution but I couldnt use the Date column in my IF statement (picture attached below). This is what I'm trying to solve

sample.png

 

Thank you!

Sara

@Anonymous , You are trying a measure I suggested a column

Column =

if(Table[Date] <=date(2020,04,30) ,[Item sold] *2, [item sold]*1.5)

 

measure =

if(max(Table[Date]) <=date(2020,04,30) ,Sum(Table[Item sold]) *2, Sum(Table[item sold])*1.5)

 

day need to be in row context

or try  like

Sumx(values(Table[date]),if(max(Table[Date]) <=date(2020,04,30) ,Sum(Table[Item sold]) *2, Sum(Table[item sold])*1.5))

Anonymous
Not applicable

Thankyou! The max one works and give me the result that I want

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.