Forum Discussion

ashmitp869's avatar
ashmitp869
Responsive Resident
2 years ago
Solved

Put Case when condition in Columns - power query transform data

Hi All ,

I need to put as logic like in one column 

CASE WHEN 

TAC
TAF
TAI
TAT
TCA
TEA

Then

Travel & Accomodation

When

SRT
SSA
SSC
SSD
STC
SWS

Then "SubContractor".

What is the easiest way to tranform.

 

I know Conditional formating 

But want to know if there is any other quick way to do,

 

Thanks

  • Hi ashmitp869 - you can create a new column using SWITCH function as below:

    ExpenseCategory =
    SWITCH(
    TRUE(),
    'Expenses'[ExpenseCode] IN {"TAC", "TAF", "TAI", "TAT", "TCA", "TEA"}, "Travel & Accomodation",
    'Expenses'[ExpenseCode] IN {"SRT", "SSA", "SSC", "SSD", "STC", "SWS"}, "SubContractor",
    "Other"
    )

    Hope it works

     

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!

1 Reply

  • Hi ashmitp869 - you can create a new column using SWITCH function as below:

    ExpenseCategory =
    SWITCH(
    TRUE(),
    'Expenses'[ExpenseCode] IN {"TAC", "TAF", "TAI", "TAT", "TCA", "TEA"}, "Travel & Accomodation",
    'Expenses'[ExpenseCode] IN {"SRT", "SSA", "SSC", "SSD", "STC", "SWS"}, "SubContractor",
    "Other"
    )

    Hope it works

     

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!