Forum Discussion
Sithi1984
Nov 17, 2020Copper Contributor
How to add a column with previous week values in Power Query/Power Bi
I have a set of weekly data, I just want to add the previous week's amount next to current week's Amount. This will help me to find the difference between the weeks. I have attached he sample fi...
- Nov 17, 2020
You may merge the table with itself using Prior Week on left side and Week on right one , like
#"Merged Queries" = Table.NestedJoin( #"Promoted Headers", {"Subscription Code", "Product Category", "Prior Week"}, #"Promoted Headers", {"Subscription Code", "Product Category", "Week"}, "Promoted Headers", JoinKind.LeftOuter ),
Just expand Amount after that and apply desired cosmetic.
Sithi1984
Copper Contributor
mathetes Thanks for the quick response!
How can we achieve this using Power query (M Language)?
Any idea?
SergeiBaklan
Nov 17, 2020MVP
You may merge the table with itself using Prior Week on left side and Week on right one , like
#"Merged Queries" = Table.NestedJoin(
#"Promoted Headers", {"Subscription Code", "Product Category", "Prior Week"},
#"Promoted Headers", {"Subscription Code", "Product Category", "Week"},
"Promoted Headers",
JoinKind.LeftOuter
),
Just expand Amount after that and apply desired cosmetic.
- Sithi1984Nov 17, 2020Copper Contributor
SergeiBaklan mathetes Thank you both for the solution.
- SergeiBaklanNov 18, 2020MVP
Sithi1984 , glad to help