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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MeganMarkey
New Member

Concatenate EXCEPT where blank

Hey everyone!

 

I have 2 columns which I'm trying to concatenate with a "/" - However, in some instances, the 'Tr.prt' column is blank. Where this occurs, I don't want the concatenation to happen at all. Basically, in the 'Relationship' column I only want to see "xxxx/xxxx" or a blank/nothing. Can anyone help? 🙂

 

MeganMarkey_0-1752658134894.png

 

12 REPLIES 12
v-veshwara-msft
Community Support
Community Support

Hi @MeganMarkey ,
Just wanted to check if the responses provided were helpful. If further assistance is needed, please reach out.
Thank you.

Riny_vE
Frequent Visitor

Wouldn't this work?

Relationship = IF(LEN(TRIM(GIT[Tr.Prt]))=0,BLANK(),GIT[CoCd]&"/"&GIT[Tr.Prt])

Hi @Riny_vE ,

Thanks for the suggestion.

Yes, the expression you provided works well as a calculated column when used within the same table:

Relationship = IF(LEN(TRIM([Tr.prt])) = 0, BLANK(), [CoCd] & "/" & [Tr.prt])


I tested this in the sample file and it gives the expected output, handling both blank and whitespace-only values in Tr.prt.

Appreciate your input.

 

v-veshwara-msft
Community Support
Community Support

Hi @MeganMarkey ,

Thanks for posting in Microsoft Fabric Community.

As suggested by @mdaatifraza5556 and @BA_Petethe DAX based approach can help achieve your requirement effectively.

 

If you prefer to use Power Query, as recommended by @collinsg , you can try the following expression:

= if [Tr.prt] = "" then "" else [CoCd] & "/" & [Tr.prt]

This works well if Tr.prt column contains only empty strings ("") and no null values.

 

To make it more robust, especially in cases where Tr.prt might contain spaces or nulls (common when data is from Excel or other sources), you can use this version:

= if Text.Trim([Tr.prt]) = "" or [Tr.prt] = null then "" else [CoCd] & "/" & [Tr.prt]

This ensures that even spaces or nulls are treated as blank, and Relationship column will only show values like CoCd/Tr.prt when both parts are present.

 

Hope this helps. Please reach out for further assistance.

Thanks again to @BA_Pete , @mdaatifraza5556 and @collinsg for your valuable guidance.

Attached is the .pbix file for reference.
Thank you.

collinsg
Super User
Super User

Good day MeganMarkey,

It may be that the solutions given do not work for as they are DAX solutions and you may be working in Power Query. As you posted in the Power Query forum I'll give you a Power Query solution. Add a custom column using the following code,

= if [Tr.prt] = "" then "" else [CoCd] & "/" & [Tr.prt]

Hope this helps

collinsg_0-1753192634993.png

 

mdaatifraza5556
Super User
Super User

Hi @MeganMarkey 

 

Can you please try the below dax.

Relationship =
IF (
    'GIT'[Tr.prt] = BLANK(),
    BLANK(),
    'GIT'[CoCd] & "/" & 'GIT'[Tr.prt]
)

IF this answers your questions, kindly accept it as a solution and give kudos.

 

Why would this work when we already know the below doesn't?

Relationship =
IF(
    NOT ISBLANK(GIT[Tr.prt]),
    GIT[CoCd] & "/" & GIT[Tr.prt]
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Value that appears to be blank (e.g., an empty string) is not treated as BLANK( ).

 

If it shows Empty String, ISBLANK( ) will return FALSE.


To treat both ""(empty string) and BLANK( ) as blank ----> use 
                                check = GIT[Tr.prt] = BLANK() 

                                               or

                                Check = TRIM(GIT[Tr.prt]) <> ""

 

Below are the snapshot of each calculated column using the dax and what it's returning 

 

Screenshot 2025-07-17 095840.png

 

Screenshot 2025-07-17 095847.png

 

Screenshot 2025-07-17 095856.png

 

Screenshot 2025-07-17 095904.png

 

 

 

If this answers your questions, kindly accept it as a solution and give kudos.

 

Hey @mdaatifraza5556 ,

 

Thanks for the great explanation and examples. I've learned something new here!

Based on the above change, you could simplify your code a little bit as follows, but yours is the correct solution 👍

Relationship_extra = 
IF (
    'GIT'[Tr.prt] <> BLANK(),
    'GIT'[CoCd] & "/" & 'GIT'[Tr.prt]
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




BA_Pete
Super User
Super User

Hi @MeganMarkey ,

 

Try the following instead:

Relationship =
IF(
    NOT ISBLANK(GIT[Tr.prt]),
    GIT[CoCd] & "/" & GIT[Tr.prt]
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hey @BA_Pete ,

 

Unfortunately that hasn't worked 😞 Although when I read your response I was convinced it would! Just to check, am I missing something in making PBI recognise the cells as 'blank'? Or is being empty enough?

 

Thanks!

 

In DAX terms, empty is BLANK().

It sounds like you may have space (" ") or other special characters in your cells rather than them being truly empty/BLANK().

Some upstream data cleaning may be in order here.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.