Forum Discussion
Need help on DAX function
- 1 year ago
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]
)
)
) - Anonymous1 year ago
Hi Learner-PBI ,
NewColumn = IF('Table'[column1] = BLANK() && 'Table'[Column2] = BLANK(), "null", 'Table'[Column1] & "-" & 'Table'[Column2])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] )The logic of the code provided by bhanu_gautam is fine, the problem should be in the emptystring with some features of ISBLANK():
Best Regards,
Gao
Community Support TeamIf 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
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
- Learner-PBI1 year agoNew Member
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]))
- bhanu_gautam1 year agoSuper User
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]
)
)
)