Forum Discussion
Difference column in a matrix
Hi,
i'd calculate the difference in a matrix between values from the same column [HRS_PLAN_DELTA], for each IDS in the same date, for different ID_Report.
Do you have some ideas ?
Dom
Hi Anonymous ,
To pivot the table and add a custom column in power query can get the excepted result we need. M code for your refernce.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc7LCUAhDETRXrIWdEafn1rE/ttQwgskCyFwSK57CwhJoi8js2C98ZOTjKhEo+6oKlWj6agpNSPgN+r1EAOd9VjDcDZizq/NmHs/ORc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, IDS = _t, Date = _t, HRS_PLAN_DELTA = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"IDS", Int64.Type}, {"Date", type date}, {"HRS_PLAN_DELTA", Int64.Type}}), #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"IDS"}), #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Removed Columns", {{"ID", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Columns", {{"ID", type text}}, "en-US")[ID]), "ID", "HRS_PLAN_DELTA", List.Sum), #"Added Custom" = Table.AddColumn(#"Pivoted Column", "Custom", each [121]-[122]) in #"Added Custom"Regards,
Frank
7 Replies
- AnonymousNot applicable
This is quite similar in principle to this solution: https://community.powerbi.com/t5/Desktop/Difference-between-rows-with-different-categories/m-p/657026#M315361 - you could try using this type of solution to search for the row values to compare.
However, you will have to be more specific on what you are trying to achieve to get a solution that works.
Can you show your expected result and the working for one example?
- AnonymousNot applicable
Hi,
i'd a result like this:
Dom- AnonymousNot applicableIf you can paste you data in that would be great