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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
MichelleQLi
Regular Visitor

If function or switch function to replace value

I have a table looking like below screenshot. 

I am not that familiar with Power BI DAX syntax, May I get some help to achieve below outcome:

 

A new colume to have:

 

if column 1 equals to "I"

and if Table3.Column6  not null

 

then use Table3.Column6 value to replace Column6 value

else remain Column6 value

 

MichelleQLi_0-1670972726607.png

 

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @MichelleQLi ,

 

For simple conditional columns you can use the Add Conditional Column feature in the Query Editor. By the way, this editor uses M as the language. DAX is used once you've loaded your data into the model.

https://turbofuture.com/computers/A-Comparison-Between-M-Language-and-DAX-in-Power-BI 

danextian_0-1670973774462.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

v-tangjie-msft
Community Support
Community Support

Hi @MichelleQLi ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1672301386764.png

(2) We can create a calculated column.

Column = IF('Table'[Column1]=="I" && 'Table'[Table3.Column6]<>BLANK(),'Table'[Table3.Column6],'Table'[Column6])

(3) Then the result is as follows.

vtangjiemsft_1-1672301519127.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
v-tangjie-msft
Community Support
Community Support

Hi @MichelleQLi ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1672301386764.png

(2) We can create a calculated column.

Column = IF('Table'[Column1]=="I" && 'Table'[Table3.Column6]<>BLANK(),'Table'[Table3.Column6],'Table'[Column6])

(3) Then the result is as follows.

vtangjiemsft_1-1672301519127.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

danextian
Super User
Super User

Hi @MichelleQLi ,

 

For simple conditional columns you can use the Add Conditional Column feature in the Query Editor. By the way, this editor uses M as the language. DAX is used once you've loaded your data into the model.

https://turbofuture.com/computers/A-Comparison-Between-M-Language-and-DAX-in-Power-BI 

danextian_0-1670973774462.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.