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.
I am looking to creating a "key" column with the only certain column names and values for those not null.
An examples is....
| A | B | C | ->>> | key |
| 1 | null | 3 | ->>> "A=1,C=3"
| null | 2 | null | ->>> "B=2"
| 2 | 4 | 5 | ->>> "A=2,B=4,C=5"
Is there a way of extracting only column names where value is not null and creating a key column like the one above?
Solved! Go to Solution.
HI @spencerhoyle ,
In my opinion ,you need to create three column ,then combine:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQKhWJ1oEG2ExAYiYzDbECoB5MUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [a = _t, b = _t, c = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"a", Int64.Type}, {"b", Int64.Type}, {"c", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom1", each if [a] is null and [b] is null then ""
else if [a] <>null and [b] is null then "a="&Number.ToText([a]) else "a="&Number.ToText([a])&","),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom2", each if [b] is null and [c] is null then ""
else if [b] <>null and [c] is null then "b="&Number.ToText([b]) else "b="&Number.ToText([b])&","),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom3", each if [c] is null then "" else "c="&Number.ToText([c])),
#"Added Custom3" = Table.AddColumn(#"Added Custom2", "Final", each [Custom1]&[Custom2]&[Custom3]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom3",{"Custom1", "Custom2", "Custom3"})
in
#"Removed Columns"
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Lucien
HI @spencerhoyle ,
In my opinion ,you need to create three column ,then combine:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQKhWJ1oEG2ExAYiYzDbECoB5MUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [a = _t, b = _t, c = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"a", Int64.Type}, {"b", Int64.Type}, {"c", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom1", each if [a] is null and [b] is null then ""
else if [a] <>null and [b] is null then "a="&Number.ToText([a]) else "a="&Number.ToText([a])&","),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom2", each if [b] is null and [c] is null then ""
else if [b] <>null and [c] is null then "b="&Number.ToText([b]) else "b="&Number.ToText([b])&","),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom3", each if [c] is null then "" else "c="&Number.ToText([c])),
#"Added Custom3" = Table.AddColumn(#"Added Custom2", "Final", each [Custom1]&[Custom2]&[Custom3]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom3",{"Custom1", "Custom2", "Custom3"})
in
#"Removed Columns"
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Lucien
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
118 | |
79 | |
47 | |
45 | |
32 |
User | Count |
---|---|
172 | |
90 | |
66 | |
46 | |
45 |