Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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! 

  • 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))

4 Replies

  • 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's avatar
      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

       

      Thank you!

      Sara

      • amitchandak's avatar
        amitchandak
        Icon for Super User rankSuper User

        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))