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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Concatenate text based on if condition

Hello, 

 

I need to concatenate text based on several columns with if condition.

My formula is the following:

(if [column1] <> 0 then "1" else "") & (if [Column2] <> 0 then "2" else "") & (if [Column3] <> 0 then "3" else ""))

 

My goal is to get "123" if none of my columns have a zero value, but I'd like to get "12" or "13" or "1" if some of my columns contain zero values. Yet, the else "" creates an error, it seems that power BI can't concatenate values if one of the value is "".

Do you have any idea of how to solve this issue ? 

 

Thanks !

1 ACCEPTED SOLUTION

@Anonymous 

also works fine.

1.PNG

Could you please check if all the data in these three columns are number not text?





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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@Anonymous 

Did you do this in PQ?

It looks fine on my end.

= Table.AddColumn(#"Changed Type", "Custom", each (if [Column1] <> 0 then "1" else "") & (if [Column2] <> 0 then "2" else "") & (if [Column3] <> 0 then "3" else ""))

1.PNG

 





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

Proud to be a Super User!




Anonymous
Not applicable

Hello,

 

Thank your for your answer, but did you try if it works if the 0 is in Column2 ? 

@Anonymous 

also works fine.

1.PNG

Could you please check if all the data in these three columns are number not text?





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

Proud to be a Super User!




Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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