Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I hope someone can help me.
I have a table with some projects and each project have several versions, furtheremore those versions have lots of sales within the version. My table is something like this:
Project ID | Versión | Sales |
1 | 0 | 10 |
1 | 0 | 20 |
1 | 1 | 100 |
1 | 2 | 30 |
1 | 2 | 40 |
2 | 0 | 15 |
2 | 0 | 70 |
2 | 1 | 15 |
2 | 1 | 20 |
2 | 1 | 15 |
3 | 0 | 20 |
3 | 1 | 50 |
3 | 2 | 30 |
I would like to get a table filtering only the latest version of each project (and making the sum of the sales column), so the result wuold be like this:
Project ID | Versión | Sales |
1 | 2 | 70 |
2 | 1 | 50 |
3 | 2 | 30 |
Thank you all in advance.
Solved! Go to Solution.
You don't even need DAX for this.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIAYkMDpVgdBNcIwQVjAwTfCIiNUbkmEK4RzCxTFK45QtYQVdYQYROarDGqO4yhsqYILswZsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project ID" = _t, Versión = _t, Sales = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Project ID", Int64.Type}, {"Versión", Int64.Type}, {"Sales", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Project ID", "Versión"}, {{"Sales", each List.Sum([Sales]), type nullable number}}),
#"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Project ID", Order.Ascending}, {"Versión", Order.Descending}}),
#"Grouped Rows1" = Table.Group(#"Sorted Rows", {"Project ID"}, {{"Version", each List.Max([Versión]), type nullable number}, {"Sales", each _, type table [Project ID=nullable number, Versión=nullable number, Sales=nullable number]}}),
#"Replaced Value" = Table.ReplaceValue(#"Grouped Rows1",each [Sales],each [Sales]{0},Replacer.ReplaceValue,{"Sales"}),
#"Expanded Sales" = Table.ExpandRecordColumn(#"Replaced Value", "Sales", {"Sales"}, {"Sales.1"})
in
#"Expanded Sales"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
Hi, @Enric21
Could you please tell me whether your problem has been solved?
If yes, please accept the helpful answer as solution to close this thread.
Best Regards,
Community Support Team _ Eason
You don't even need DAX for this.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIAYkMDpVgdBNcIwQVjAwTfCIiNUbkmEK4RzCxTFK45QtYQVdYQYROarDGqO4yhsqYILswZsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project ID" = _t, Versión = _t, Sales = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Project ID", Int64.Type}, {"Versión", Int64.Type}, {"Sales", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Project ID", "Versión"}, {{"Sales", each List.Sum([Sales]), type nullable number}}),
#"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Project ID", Order.Ascending}, {"Versión", Order.Descending}}),
#"Grouped Rows1" = Table.Group(#"Sorted Rows", {"Project ID"}, {{"Version", each List.Max([Versión]), type nullable number}, {"Sales", each _, type table [Project ID=nullable number, Versión=nullable number, Sales=nullable number]}}),
#"Replaced Value" = Table.ReplaceValue(#"Grouped Rows1",each [Sales],each [Sales]{0},Replacer.ReplaceValue,{"Sales"}),
#"Expanded Sales" = Table.ExpandRecordColumn(#"Replaced Value", "Sales", {"Sales"}, {"Sales.1"})
in
#"Expanded Sales"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
105 | |
78 | |
68 | |
63 |
User | Count |
---|---|
148 | |
107 | |
106 | |
84 | |
70 |