Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I created a custom column to concatinate two fields from transformation -> Add column -> custom column
The formula is custom = [A] & [B]. If either if the colums value is null the result is null.
The null should be allowed only if both are null. how do i do this ?
Solved! Go to Solution.
Hi, @kannanAhammed , Null Coalescing Operator (??) does the trick
Table.AddColumn(#"Replaced Value", "Custom", each ([A]??"") & ([B]??"") & ([C]??""))
Just for fun, let's say, if you want to combine all columns (more than 10 columns) in a row, you might use the following code,
Table.AddColumn(#"Replaced Value", "Custom", each List.Accumulate(Record.ToList(_), "", (s,c)=>s&(c??"")))
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi @kannanAhammed ,
You can directly use the expression custom=[A]&[B] to create a Calculated column, and you can get a column concatenating these two fields. If both of the fields are null, the result will be null.
The result looks like this:
Best Regards,
Caiyun Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Your question isn't clear because you say
The first one means the result is null if either A or B is null.
The second one means the result is null only if A and B are null.
You can't have both. If it's null only when A and B are null then the first condition is invalid. Which is it?
I imagine the other answers will give you a solution but just needed to point out the question isn't logically clear.
Regards
Phil
Proud to be a Super User!
Hi, @kannanAhammed , Null Coalescing Operator (??) does the trick
Table.AddColumn(#"Replaced Value", "Custom", each ([A]??"") & ([B]??"") & ([C]??""))
Just for fun, let's say, if you want to combine all columns (more than 10 columns) in a row, you might use the following code,
Table.AddColumn(#"Replaced Value", "Custom", each List.Accumulate(Record.ToList(_), "", (s,c)=>s&(c??"")))
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@kannanAhammed , Try like
if [A] <> null && [B] <> null then [A] & [B] else if [A] <> null then [A] else [B]
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
78 | |
63 | |
52 | |
47 |
User | Count |
---|---|
212 | |
82 | |
61 | |
61 | |
60 |