Forum Discussion

ABLRP's avatar
ABLRP
Regular Visitor
4 years ago
Solved

IF statement not working properly

Hello,

 

I am trying to do an easy if and such as below.

 

Then I want to count how many 1, 2 and 3 I have, and this is not working. It only shows 3.

Firts I could not use category=Cons because I am using direct query so I created a category code (Cons is category code 3).

 

Cost ABC2 =
if(
'MEASURES CONS'[Most Recent Price] >= 1000 && 'MEASURES ABC'[Category Code]=3, 1,
if(
'MEASURES CONS'[Most Recent Price] >= 250 && 'MEASURES CONS'[Most Recent Price] < 1000 && 'MEASURES ABC'[Category Code]=3, 2,
if(
'MEASURES CONS'[Most Recent Price] <= 250 && 'MEASURES ABC'[Category Code]=3, 3
)))
 
Am I doing something wrong?
  • Hi there,

    A simple solution would be to use your measure you created but do it as a calculated column instead of a measure. You would set the column as the legend/column 1 and then column 2 of the table you would use the same column except set the column operation = count. 

     

    Hope that helps. 

4 Replies

  • Hi there,

    A simple solution would be to use your measure you created but do it as a calculated column instead of a measure. You would set the column as the legend/column 1 and then column 2 of the table you would use the same column except set the column operation = count. 

     

    Hope that helps. 

  • ABLRP's avatar
    ABLRP
    Regular Visitor

    Hi Jarom,

     

    Thank you for the help. The problem is that I have a table with all orders and I only want to categorize (1,2,3) according the most recent price. In this case I would be evaluating the same PN on different prices...

    • JaromBIDEVatDK's avatar
      JaromBIDEVatDK
      Helper II

      Is the current price it's own column so for every Row of a PN the current price is shown? Or are you using a date or some flag to identify which record is the current price? If the latter then you can do as I mentioned before and just add a filter to the visual for "current"  eq 1

  • ABLRP's avatar
    ABLRP
    Regular Visitor

    Exactly, I am using a flag using the most recent date. I will try your suggestion 🙂 thank you