-1

enter image description here

Why does this code fail?

Acknowledge that the "Amounts" column is intentionally of type text. I can use List.Sum and Number.From in conjunction with say Table.AddColumn, and all works out as you would expect. The numeral of type text is converted to a numeral of type number, and the summation is done.

However, when I use List.Sum and Number.From in conjunction with Table.Group, this code fails:

= Table.Group(
    #"Changed Type",
    {"Name"},
    {
        {"Amount", each Text.Combine([Amounts], "/"), type nullable text},
        {"Total Amount", each List.Sum({Number.From([Amounts])}), type nullable number}
    }
)
2
  • 2
    = Table.Group( #"Changed Type", {"Name"}, { {"Amount", each Text.Combine([Amounts], "/"), type nullable text}, {"Total Amount", each List.Sum(List.Transform([Amounts], Number.From)), type nullable number} } ) try this one Commented Nov 4 at 12:08
  • If you have values in Amounts as shown, then Table.AddColumn(....., each List.Sum(Number.From([Amounts])) will return an error, contrary to what you write. (I suspect what you wrote is incorrect). Number.From must have only a single value for it's argument. Within your Table.Group function, [Amounts] represents a List of all the entries in the Amounts column of the grouped table. In the Table.AddColumn function, it will only represent the single value on the same row. The solution by @hansraj should work for you. Commented Nov 21 at 21:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.