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.
I've looked at several other forums, however, none quite match my problem.
I want to sum all values in a row, if they match a certain category to create a new column.
I am starting with this table:
Name, Month, Value
Bob | 2017-12 | 45 |
Bob | 2017-12 | 100 |
Sally | 2017-12 | 65 |
Sally | 2017-11 | 5 |
Bob | 2017-11 | 10 |
But I want to create a measure or new column for each month which totals all of the values for a given person in a given month, so I want to change the table to:
Name, 2017-11, 2017-12
Bob | 10 | 145 |
Sally | 5 | 65 |
I'm pretty new to Power BI and DAX language, so I'm having trouble getting something to work.
Solved! Go to Solution.
@Anonymous Please try "Grouping" and "Pivot" in Power Query Editor as below
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcspPUtJRMjIwNNc1NAKyTEyVYnUwhQ0NDMDiwYk5OZUoMmamWCQMgSxMgwzBBinFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Month = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Month", type date}, {"Value", Int64.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Name", "Month"}, {{"Value", each List.Sum([Value]), type number}}), #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Grouped Rows", {{"Month", type text}}, "en-GB"), List.Distinct(Table.TransformColumnTypes(#"Grouped Rows", {{"Month", type text}}, "en-GB")[Month]), "Month", "Value") in #"Pivoted Column"
Proud to be a PBI Community Champion
@Anonymous Please try "Grouping" and "Pivot" in Power Query Editor as below
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcspPUtJRMjIwNNc1NAKyTEyVYnUwhQ0NDMDiwYk5OZUoMmamWCQMgSxMgwzBBinFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Month = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Month", type date}, {"Value", Int64.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Name", "Month"}, {{"Value", each List.Sum([Value]), type number}}), #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Grouped Rows", {{"Month", type text}}, "en-GB"), List.Distinct(Table.TransformColumnTypes(#"Grouped Rows", {{"Month", type text}}, "en-GB")[Month]), "Month", "Value") in #"Pivoted Column"
Proud to be a PBI Community Champion
@Anonymous you can also achieve this by matrix visual by
add name on rows
add month on columns
add value on value
voila, you have the solution.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
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 |
---|---|
113 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |