Power Query New Column Concatenate Problem

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I created a new column and contatenated these values without any problems.

= Table.AddColumn(#"Added Custom2", "Detail Comments", each "{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}" & " " & "{Tariff: $" & Number.ToText([#"Tariff Cost $"]) & "}" & " " & "{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}")

{Excess Cost: $500.25} {Tariff: $205.78} {Excess Cost: $500.25}

But I wanted to add a Comment column (Text) to it. Once I do this the new column is blank. can someone explain what I am doing wrong?

[Qty Comment] &"{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}" & " " & "{Tariff: $" & Number.ToText([#"Tariff Cost $"]) & "}" & " " & "{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}"

The Formula does not tell me I have a syntax error so I dont understand why this does not work. it comes up null.

Thanks for the help.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try it like this:

Power Query:
each let QC = [Qty Comment] in (if QC=null then "" else QC) &"{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}" & " " & "{Tariff: $" & Number.ToText([#"Tariff Cost $"]) & "}" & " " & "{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}"

Joining a null with anything will return null, so the code above changes the null to zero length text. If any of the other columns you're concatenating might contain a null you will need to do something similar with them.

If the embedded "let ... in" bothers you, this will do the same thing a little less efficiently:

Power Query:
each (if [Qty Comment] =null then "" else [Qty Comment]) &"{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}" & " " & "{Tariff: $" & Number.ToText([#"Tariff Cost $"]) & "}" & " " & "{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}"
 
Upvote 0
Solution
If your version supports it, you can also use the coalesce operator:

Power Query:
([Qty Comment]??"") &"{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}" & " " & "{Tariff: $" & Number.ToText([#"Tariff Cost $"]) & "}" & " " & "{Excess Cost: $" & Number.ToText([#"Excess Material Cost $"]) & "}"

or use Text.Combine and pass the sections as a List.
 
Upvote 0

Forum statistics

Threads
1,223,677
Messages
6,173,788
Members
452,534
Latest member
autodiscreet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top