Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dwhittaker1
Helper I
Helper I

Conditional Column in DirectQuery

What is the best way to create a conditional column in direct query with multiple conditions. I would like the condition to state the following.

 

If Original Column = A then T, else if Original Column = B then U, else if Original Column = C then V, else if Original Column = D then W. If none of the criteria is met then return Original Column.

 

See the table below for output

 

Original Column      New Column    
AT
BU
CV
DW
EE
FF
GG
HH
II
1 ACCEPTED SOLUTION
PijushRoy
Super User
Super User

Hi @dwhittaker1 

In Power BI desktop, please create a calculated column and paste the below DAX (update the dax as per your requirement)

 

New Column = SWITCH(
    TRUE(),
    'Table'[Original Column] IN {"A"},"T",
'Table'[Original Column] IN {"B"},"U",
'Table'[Original Column] IN {"C"},"V",
'Table'[Original Column])

 

 


Let me know if that works for you


If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the Thumbs Up 👍 button if this comment helps you.

Thanks
Pijush
Linkedin

View solution in original post

1 REPLY 1
PijushRoy
Super User
Super User

Hi @dwhittaker1 

In Power BI desktop, please create a calculated column and paste the below DAX (update the dax as per your requirement)

 

New Column = SWITCH(
    TRUE(),
    'Table'[Original Column] IN {"A"},"T",
'Table'[Original Column] IN {"B"},"U",
'Table'[Original Column] IN {"C"},"V",
'Table'[Original Column])

 

 


Let me know if that works for you


If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the Thumbs Up 👍 button if this comment helps you.

Thanks
Pijush
Linkedin

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.