Forum Discussion

Saaharjit's avatar
Saaharjit
Helper I
8 years ago

How to compare two columns

I have two columns in my matrix, Sales_price and Total_value. I want to compare the two columns and generate a 3rd column. The 3rd column will have values based on the comparison on the 2 columns. If the values of the Sales_price column is lesser than the total of Total_value column then print the Sales_price value in the 3rd column. If Sales_price is higher than the total of Total_value then print total of total value column on the 3rd column.

 

For eg:- 

 

in the image below.

 

Sales_price = 2,303.08

Sum(Total_value) = 13,801

Actual Price(3rd column) = 2,303.08

 

 

7 Replies

  • Hi Saaharjit ,

     

    You can do this by two ways either create calculated column in table adn define your logic there

    or create new measure which will use your existing 2 measurs to derive third measure.

     

     

    Plesae mark as solution if this works for you !!!!!!!!!!!!!!!!!!!

    Thank you :smileyhappy:

    • Saaharjit's avatar
      Saaharjit
      Helper I

      BalaVenuGopal 

       

      This is what i did.  

       

      MAXSALESVALUE = MAX(Query1[Sales_price])

       

      SumOfTotalValue = CALCULATE(SUM(Query1[Total_value]),ALLSELECTED(Query1[WORK_ORDER_NUMBER]) )

       

      WIPMAX(3rd column) = WIPMAX = IF([SumOfTotalValue] > [MAXSALESVALUE],[MAXSALESVALUE],[SumOfTotalValue])

       

      I am getting the correct values but for some reason the grand total is wrong. It should be somewhere close to 3 million