Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi everyone,
I have the following table in PowerQuery:
| Date | Value |
| 01/01/2000 | 23655 |
| 01/01/2001 | 36985 |
| 01/01/2002 | 65987 |
I would like to add a colomn with the year-to-year growth. This means that for each row, I would look up the value of the year before and divide it and substract 1. I know how to do this with DAX, but in my use case I need to make use of M Query language and I am not finding any resources online. Could anyone help me with this?
Solved! Go to Solution.
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDBQ0lEyMjYzNVWK1YELGgIFjc0sLVAEjYCCZqaWFuZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "%YoY", each try Number.Round([p=List.Buffer(#"Added Index"[Value]){[Index]-1}, YoY= ([Value]-p)/p*100][YoY],2) otherwise null, type number),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
#"Removed Columns"
👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)
How to get your questions answered quickly -- How to provide sample data
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDBQ0lEyMjYzNVWK1YELGgIFjc0sLVAEjYCCZqaWFuZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "%YoY", each try Number.Round([p=List.Buffer(#"Added Index"[Value]){[Index]-1}, YoY= ([Value]-p)/p*100][YoY],2) otherwise null, type number),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
#"Removed Columns"
👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)
How to get your questions answered quickly -- How to provide sample data
Hi, I forgot to mention, the table actually looks like this:
| Date | Country | Value |
| 01/01/2000 | DE | 12345 |
| 01/01/2001 | DE | 6789 |
| 01/01/2000 | FR | 4567 |
| 01/01/2001 | FR | 1236 |
How can I achieve the same but the growth numbers are calculated per country? Thanks!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 5 | |
| 5 | |
| 3 |