I have a table - each row has columns for percentages of different categories plus a column for total value, and I want to calculate the value for each category by multiplying the total value by each category percentage.
I have a table, and, for each of the other columns (Market Cap.Large
, Market Cap.Medium
etc. - all except Symbol
) I want to multiply it by the Current Value
column. I can do it manually and add a column for each (the #"Added Custom"
line below), but the number of columns may increase and the titles may change, so I don't want to have to input a custom column for each.
Is there a recursive expression to create a new column for each of the existing ones, and multiply it by Current Value
- I'm guessing it would involve creating a parameter for the column name, but I'm not knowledgeable enough on how to do it.
let
Source = #"Portfolio %",
#"Merged Queries" = Table.NestedJoin(Source,{"Symbol"},#"Current Output Aggregated",{"Symbol"},"Current Output Aggregated",JoinKind.Inner),
#"Expanded Current Output Aggregated" = Table.ExpandTableColumn(#"Merged Queries", "Current Output Aggregated", {"Current Value"}, {"Current Value"}),
#"Added Custom" = Table.AddColumn(#"Expanded Current Output Aggregated", "Market Cap.Giant Value", each [Market Cap.Giant]*[Current Value])
in
#"Added Custom"