Forum Discussion

Tan_LC's avatar
Tan_LC
Helper II
2 years ago
Solved

Compare multiple columns in same table

Hi, in below table, I would like to retrieve a string value by comparing to the other 3 columns, Category, Rank & Pin with below conditions:

 

1. If the Rank is "OE", then the result shall be "OE".

2. If the Pin is Stud or Studless, then the result shall be "Stud" or "Studless".

3. Else, it shall follow Category, either "PR" or "LT".

 

 

NoCategoryRankPinDesired Outcome
Y1PRREOthersPR
N3PRREStudStud
P1PROEOthersOE
S1LTREStudlessStudless
A2LTREOthersLT

 

Thanks.

Regards, LC

  • Tan_LC , You can get the desired result by creating a custome column go to modelling view select new column

     

    dax
    DesiredOutcome =
    SWITCH(
    TRUE(),
    'YourTable'[Rank] = "OE", "OE",
    'YourTable'[Pin] = "Stud", "Stud",
    'YourTable'[Pin] = "Studless", "Studless",
    'YourTable'[Category] = "PR", "PR",
    'YourTable'[Category] = "LT", "LT",
    BLANK()
    )

     

    Replace table name 

1 Reply

  • Tan_LC , You can get the desired result by creating a custome column go to modelling view select new column

     

    dax
    DesiredOutcome =
    SWITCH(
    TRUE(),
    'YourTable'[Rank] = "OE", "OE",
    'YourTable'[Pin] = "Stud", "Stud",
    'YourTable'[Pin] = "Studless", "Studless",
    'YourTable'[Category] = "PR", "PR",
    'YourTable'[Category] = "LT", "LT",
    BLANK()
    )

     

    Replace table name