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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Connect 2 column in power query but the result turn to null

I want to create new column by using custom column function in Power Query Editor.

New_Column = [Column A] & "-" & [Column B]  

when the [Comlumn A] is null and the [Column B] is "Good", the result should be "-Good".

But when I used the formular as above, the result was turned that when one of these columns is null, the result of New_Column is null.

ex. [Comlumn A] is null and the [Column B] is "Good", the result was null.

[Comlumn A] is null and the [Column B] is null, the result was null.

[Comlumn A] is "Good" and the [Column B] is null, the result was null.

 

Please help me to figure it out,

Thank you 😻

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

@ImkeF's solution is great if you don't want a hyphen when one column is null.

 

If you want the hyphen (as in your specified example), then the coalesce operator is handy if you don't want to replace nulls with empty strings as a separate step or write out the equivalent if statements.

([Column A] ?? "") & "-" & ([Column B] ?? "")

AlexisOlson_0-1666469356005.png

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous ,

 

Did the answers above help you? If so, please consider marking the most helpful answer as a solution, as this will help people searching the forum for similar questions in the future to find answers more quickly. Thanks in advance!

If the question remains unresolved, you can continue to add details to the question below and feel free to contact us.

 

Best Regards,
Gao
Community Support Team

AlexisOlson
Super User
Super User

@ImkeF's solution is great if you don't want a hyphen when one column is null.

 

If you want the hyphen (as in your specified example), then the coalesce operator is handy if you don't want to replace nulls with empty strings as a separate step or write out the equivalent if statements.

([Column A] ?? "") & "-" & ([Column B] ?? "")

AlexisOlson_0-1666469356005.png

Anonymous
Not applicable

Thank you for this solution! 😍

ronrsnfld
Super User
Super User

In general, null <operator> value  => null

@ImkeF solution is an excellent one.  You could also use an If statement to convert the null to  "".

ImkeF
Community Champion
Community Champion

Hi @Anonymous ,
try using this instead:

Text.Combine( { [Column A], [Column B] },  "-" )

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Thank you so much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.