Forum Discussion
Julian_12
4 years agoNew Member
Running total with group
Hi All, I have quite complicated issue. I have the presented below data table and I need to present the total number of items per value band in stacked area chart. Please note that at each date the n...
- 4 years ago
Hi Julian_12 ,
According to your description, you need to use the pivot column function in the power query, and then replace the null values in it. Refer to the following screenshot.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZY+xDoAgDET/hZkmbRXRUf0MwqCROOnA/w+CEURJmiaXl7trjRGjkIIwLEYmQALugti9c6ew8uEqcwXIFWdOnMLEsOVYnb/5FNE/3rstwzZ7EXCovFhEc/OpnoNS1emvPXLi4vRbpO5IdYYaqK/Nqiwv/rYX", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, PurchaseItem = _t, PurchaseDate = _t, #"Value Band for product" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"PurchaseItem", Int64.Type}, {"PurchaseDate", type date}, {"Value Band for product", type text}}), #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Product"}), #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"Value Band for product"]), "Value Band for product", "PurchaseItem"), #"Sorted Rows1" = Table.Sort(#"Pivoted Column",{{"PurchaseDate", Order.Ascending}}), #"Replaced Value" = Table.ReplaceValue(#"Sorted Rows1",null,0,Replacer.ReplaceValue,{"green", "amber", "red"}) in #"Replaced Value"If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Julian_12
4 years agoNew Member
Hi amitchandak, yes, but the real question is how to calculate the second table from the first one.
amitchandak
4 years agoSuper User
Julian_12 , If only want to display matrix would do that ?
Date on row, Value brand per item on the column, and no of the purchased item on values.
Else unpivot the table in power query