cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
abukapsoun
Helper V
Helper V

Renaming field based on criteria

Hi Gents,

 

I have the following table:

col1 col2

A       R

B       S 

C       T

D       W

 

I would like to rename the field in Column1 based on the following:

if col2 value = R or S or W then col1 value is Blue

and if col2 value = T or ..or.. then col1 value is Red

 

Thanks,

 

4 REPLIES 4
amitchandak
Super User
Super User

@abukapsoun , You can create a new column in DAX

 

col3 = if( [col2] in {"R", "S", "W"},"Blue", "Red")



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Thanks, is there an elseif  because I have different criterias, i.e Blue, Red, Green, Purple.. 

Or i am thinking with the conditional column, but how to enter multiple value in the value field so I dont create 1 clause per value

 

@abukapsoun , In DAX you have Switch

 

col3 = Switch( True(),

[col2] in {"R", "S", "W"},"Blue",

// Add more conditions

"Red")

Refer my Video:https://www.youtube.com/watch?v=gelJWktlR80

Power query is if then else  and you can have if again in then or else



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!
abukapsoun
Helper V
Helper V

In the conditional formatting, how can I specify the "Or" in the value field, so I can don't create a clause per value?

Thanks,

 

abukapsoun_0-1613379752753.png

 

 

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors