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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Learner-PBI
New Member

Need help on DAX function

Hi All, I need help on DAX function:

I have need to concatenate 2 columns with "-" b/w the 2 columns to identify value to 2 columns & if the both the columns are blank then it should show value as "null". Please help me on this dax. Thank you!

2 ACCEPTED SOLUTIONS

@Learner-PBI , try this dax
NewColumn =
IF(
ISBLANK('Table'[column1]) && ISBLANK('Table'[column2]),
"null",
IF(
ISBLANK('Table'[column1]),
'Table'[column2],
IF(
ISBLANK('Table'[column2]),
'Table'[column1],
'Table'[column1] & " - " & 'Table'[column2]
)
)
)

 

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

v-cgao-msft
Community Support
Community Support

Hi @Learner-PBI ,

 

 

NewColumn = IF('Table'[column1] = BLANK() && 'Table'[Column2] = BLANK(), "null", 'Table'[Column1] & "-" & 'Table'[Column2])

 

vcgaomsft_0-1726709153302.png

Or add a condition: connect with ‘-’ only if neither column is blank:

 

NewColumn = 
SWITCH(
    TRUE(),
    'Table'[Column1]=BLANK() && 'Table'[Column2]=BLANK(), "null",
    'Table'[Column1]=BLANK(), 'Table'[Column2],
    'Table'[Column2]=BLANK(), 'Table'[Column1],
    'Table'[Column1] & "-" & 'Table'[Column2]
)

 

vcgaomsft_1-1726709276874.png

The logic of the code provided by bhanu_gautam is fine, the problem should be in the emptystring with some features of ISBLANK():

vcgaomsft_3-1726709727253.png

vcgaomsft_2-1726709587886.png

ISBLANK – DAX Guide

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum 

View solution in original post

7 REPLIES 7
v-cgao-msft
Community Support
Community Support

Hi @Learner-PBI ,

 

 

NewColumn = IF('Table'[column1] = BLANK() && 'Table'[Column2] = BLANK(), "null", 'Table'[Column1] & "-" & 'Table'[Column2])

 

vcgaomsft_0-1726709153302.png

Or add a condition: connect with ‘-’ only if neither column is blank:

 

NewColumn = 
SWITCH(
    TRUE(),
    'Table'[Column1]=BLANK() && 'Table'[Column2]=BLANK(), "null",
    'Table'[Column1]=BLANK(), 'Table'[Column2],
    'Table'[Column2]=BLANK(), 'Table'[Column1],
    'Table'[Column1] & "-" & 'Table'[Column2]
)

 

vcgaomsft_1-1726709276874.png

The logic of the code provided by bhanu_gautam is fine, the problem should be in the emptystring with some features of ISBLANK():

vcgaomsft_3-1726709727253.png

vcgaomsft_2-1726709587886.png

ISBLANK – DAX Guide

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum 

Learner-PBI
New Member

Hi, Thanks for reply. I tried the measure you had shared and I got "Error" & I tried the below function, I got the values concantenated but on the cell which had blank it didnt not show as "null" but instead I got the result as "-"

New column = if(ISBLANK('Table'[column1])&&

ISBLANK('Table'[column2]),"null",

CONCATENATE('Table'[column1],if(ISBLANK('Table'[Column1]),ISBLANK('Table'[column2])," - ")&'Table'[column2]))

That's great can you accept my reply as solution if it helped




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Would you please help with the below DAX to show as "null" if column1 & column2 is blank & not "-"

New column = if(ISBLANK('Table'[column1])&&

ISBLANK('Table'[column2]),"null",

CONCATENATE('Table'[column1],if(ISBLANK('Table'[Column1]),ISBLANK('Table'[column2])," - ")&'Table'[column2]))

@Learner-PBI , try this dax
NewColumn =
IF(
ISBLANK('Table'[column1]) && ISBLANK('Table'[column2]),
"null",
IF(
ISBLANK('Table'[column1]),
'Table'[column2],
IF(
ISBLANK('Table'[column2]),
'Table'[column1],
'Table'[column1] & " - " & 'Table'[column2]
)
)
)

 

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






bhanu_gautam
Super User
Super User

@Learner-PBI , Try below measure

 

NewColumn =
IF(
ISBLANK(Table[Column1]) && ISBLANK(Table[Column2]),
"null",
CONCATENATE(
Table[Column1],
IF(
ISBLANK(Table[Column1]) || ISBLANK(Table[Column2]),
"",
"-"
) & Table[Column2]
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






I tried the one you shared & in case of blank it shows "-" & not null

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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