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
tonijj
Helper IV
Helper IV

3 Step IF statement or Switch

Hi, 

 

After reading through several threads I got stuck and didnt manage to solve this on my own 😕  But hey, here's to a great community right! 🙂 


I have three sets of columns, A, B and C. 

What I want to achieve: 
I want PBI to populate column D with the info coming from either A, B or C. 

So in all simplicity;

If column A = blank and Column B is blank, then populate Column D with Column C.

If Column B = blank and Column C is blank, then populate Column D with Column A.

If Column C = blank and Column A is blank, then populate Column D with Column B.

 

tonijj_0-1620135107006.png


With only two columns its not difficult at all, but three...well, I surrender 🙂 


Any help appreciated!

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @tonijj ,

 

If you only have values in one of the columns try the following code:

 

 

 

Output = COALESCE ( Table[ColumnA], COALESCE ( Table[ColumnB], Table[Column C])

 

 

 

Be aware that the first value to be check will be the Column A then B then C so if you have two columns with values they  will be pick up by that order.

 

MFelix_0-1620135868355.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
tonijj
Helper IV
Helper IV

Hi @MFelix 

Thanks! That seems to work!

Quick followup question; Why would I need to use Coalesce twice? 

In the formula above its used as main DAX function, but then within the formula, after [ColumnA] again? Just wondering wether thats a typo or if Im missing something? Just asking so I learn how to use it myself next time 🙂 

Hi @tonijj ,

 

It was a typo, I was copy pasting information and must have copied entire formula, then posted the image with the error and in the code. Correct formula is:

 

 

Output = COALESCE ( Table[ColumnA], Table[ColumnB], Table[Column C])

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi @tonijj ,

 

If you only have values in one of the columns try the following code:

 

 

 

Output = COALESCE ( Table[ColumnA], COALESCE ( Table[ColumnB], Table[Column C])

 

 

 

Be aware that the first value to be check will be the Column A then B then C so if you have two columns with values they  will be pick up by that order.

 

MFelix_0-1620135868355.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.