Forum Discussion

freginier's avatar
freginier
Icon for Solution Sage rankSolution Sage
4 years ago
Solved

Dax text comparaison

Hi all I need your help !

 

I have a table like below, I need to comparaire value from category A with values from category A.1 and A.2

I need a new column with flag "same" or "different".

 

How can I do this ? 

 

CategoryValue
AABC
A.1A
A.2ABC
A.2DEF
A.3ABC
A.4DEF
  • Load your data into the power bi desktop

    Now create the flowing calculated column 
    Status =
    VAR val = data[Value]
    VAR result =
    CALCULATE ( COUNTROWS ( data ), ALL ( data ), data[Value] = val )
    RETURN
    IF ( result == 1, "different", "Same" )

    You will get your expected results. 

     

13 Replies

  • SpartaBI's avatar
    SpartaBI
    Icon for Community Champion rankCommunity Champion

    freginier hey, can you just clarify when do you want to get "Same" and when "Different"? on your sample data.

  • Load your data into the power bi desktop

    Now create the flowing calculated column 
    Status =
    VAR val = data[Value]
    VAR result =
    CALCULATE ( COUNTROWS ( data ), ALL ( data ), data[Value] = val )
    RETURN
    IF ( result == 1, "different", "Same" )

    You will get your expected results. 

     

    • freginier's avatar
      freginier
      Icon for Solution Sage rankSolution Sage

      Royel ,Thank you but I need to add a condition on Category because I can have a completly different categories like B etc. How can I do that ? Thank you !

       

      Why do we not use EARLIER function ?