Forum Discussion
Anonymous
4 years agoNot applicable
Referencing a value in the same row but in dynamic columns
Hey there, my tables looks like this: Sales in EUR USD SEK PLN CAD AUD Currency Code 22.91 1.11 3.2 4.56 1.09 1.2 EUR 9.12 1.04 3.1 4.55 1.13 0.98 PLN 7.13 1.09 ...
- 4 years ago
You can use the Record.Field method:
let Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Sales in EUR", type number}, {"USD", type number}, {"SEK", type number}, {"PLN", type number}, {"CAD", type number}, {"AUD", type number}, {"Currency Code", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Sales in Currency Code", each if [Currency Code] = "EUR" then [Sales in EUR] else Record.Field(_, [Currency Code]) * [Sales in EUR] , Currency.Type) in #"Added Custom"
ronrsnfld
Super User
4 years agoThanks.
I've been slowly learning M Code and finding there is a lot that can be done not apparent in the UI. But I don't have a feeling about what is the most efficient way of doing things. I suppose that will come with time.