Forum Discussion
pescadicto
Helper I
4 years agoHow to scale a multi-categories / multiple vales using another table with factors
Hi! I need some help: I want to scale the first table using the factors of the second table to get the third table: The indexes in the first table are repeated (you can think of them as ca...
lbendlin
Super User
4 years agopescadicto your factors table is missing the reference for index 50.
"The indexes in the first table are repeated" - that's not how an index should be used. You may need to add a true index to the TABLE table.
ImkeF How can I know which column I am currently in? This is how far I got
let
Source = TABLE,
CN = List.RemoveFirstN(Table.ColumnNames(Source),1),
#"Merged Queries" = Table.NestedJoin(Source, {"INDEX"}, FACTORS, {"INDEX"}, "FACTORS", JoinKind.LeftOuter),
#"Replaced Value" = Table.ReplaceValue(#"Merged Queries", null,each Table.Column([FACTORS],"FACTOR 2"){0},(o,c,n)=> o*n ,CN),
#"Removed Columns" = Table.RemoveColumns(#"Replaced Value",{"FACTORS"}),
Rename = Table.TransformColumnNames(#"Removed Columns",(k)=>Text.Replace(k,"VALUE","SCALED"))
in
Rename
but you can see that I hardcoded "FACTOR 2". I would need to know that I am in the "VALUE 1" column and then I would replace that column name with "FACTOR 1" for the value lookup.
I don't think Power Query supports matrix operations like "multiply table a with table b", right?
pbix is attached.
- pescadicto4 years ago
Helper I
Thanks for the answer! It's the best approach to what I need: a solution without hardcoded values.
Finally I will use this solution.