Forum Discussion

Anil2264's avatar
Anil2264
Icon for Helper I rankHelper I
4 years ago
Solved

If Condition in Column & Measure

Dear All,

 

Please guide me while i am trying to make if condition in measures then why i am not able to pick the columns of my table, it is only showing the already created other measures in dax.

 

Please guide.

  • Thanks @goncalo

    could you also please explain why columns are not picking up in if measure

3 Replies

  • Hello there Anil2264 ! You can structure you IF statement like so:

    IF = 
    var _column = SELECTEDVALUE(Table[Column Name])
    
    return
    IF(
    _column = condition,
    value if true,
    value if false (optional)
    )

    Hope this answer solves your problem! If you need any additional help please @ me in your reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️ or give it a kudoe 👍
    Thanks!

    You can also check out my LinkedIn!

    Best regards,
    Gonçalo Geraldes

  • Thanks @goncalo

    could you also please explain why columns are not picking up in if measure

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

      Hello there Anil2264 ! That happens because a measure can only have a single (scalar) value and not a hole column or table. That is why you need to either provide a scalar value or (as I did in the measure above) store the single value in a variable to then use in the RETURN. Variables are always a good choice to implement when creating expressions with filters since the variables are evaluated outside the filters your RETURN expression applies.

       

      You can refer to this link for further help.

       

      Hope this answer solves your problem! If you need any additional help please @ me in your reply.
      If my reply provided you with a solution, pleased consider marking it as a solution ✔️ or giving it a kudoe 👍
      Thanks!

      You can also check out my LinkedIn!

      Best regards,
      Gonçalo Geraldes