Forum Discussion
Help with mquery index formula
- Anonymous2 years ago
Hi RyanVSS ,
Please try the following steps:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtc3MtY3MjAyUdJRcnQEEp55aflFuakpwcn5RalAvolSrA5YmRGKMo+YUgMDI7PwYqgyY5gyQxRlwYlpqSWVweiKDPBaCVNmaEmUlYYWMGVOTjitNDRHUYThSz0zmEIzFIU4LTXFb2ksAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [createdon = _t, slgc_contact = _t, Attribute = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"createdon", type date}, {"slgc_contact", type text}, {"Attribute", type text}, {"Value", type number}}), #"Sorted Rows" = Table.Sort(#"Changed Type",{{"createdon", Order.Descending}}), #"Grouped Rows" = Table.Group(#"Sorted Rows", {"slgc_contact", "Attribute"}, {{"Data", each Table.FirstN(_,1)}}), #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"createdon", "Value"}, {"createdon", "Value"}), #"Grouped Rows2" = Table.Group(#"Expanded Data", {"slgc_contact"}, {{"LatestSession", each List.Max([createdon]), type nullable date}, {"All", each _, type table [createdon=nullable date, slgc_contact=nullable text, Attribute=nullable text, Value=nullable number]}}), #"Expanded All" = Table.ExpandTableColumn(#"Grouped Rows2", "All", {"Attribute", "Value"}, {"Attribute", "Value"}), #"Pivoted Column" = Table.Pivot(#"Expanded All", List.Distinct(#"Expanded All"[Attribute]), "Attribute", "Value") in #"Pivoted Column"Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group
Hi RyanVSS ,
Please try the following steps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtc3MtY3MjAyUdJRcnQEEp55aflFuakpwcn5RalAvolSrA5YmRGKMo+YUgMDI7PwYqgyY5gyQxRlwYlpqSWVweiKDPBaCVNmaEmUlYYWMGVOTjitNDRHUYThSz0zmEIzFIU4LTXFb2ksAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [createdon = _t, slgc_contact = _t, Attribute = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"createdon", type date}, {"slgc_contact", type text}, {"Attribute", type text}, {"Value", type number}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"createdon", Order.Descending}}),
#"Grouped Rows" = Table.Group(#"Sorted Rows", {"slgc_contact", "Attribute"}, {{"Data", each Table.FirstN(_,1)}}),
#"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"createdon", "Value"}, {"createdon", "Value"}),
#"Grouped Rows2" = Table.Group(#"Expanded Data", {"slgc_contact"}, {{"LatestSession", each List.Max([createdon]), type nullable date}, {"All", each _, type table [createdon=nullable date, slgc_contact=nullable text, Attribute=nullable text, Value=nullable number]}}),
#"Expanded All" = Table.ExpandTableColumn(#"Grouped Rows2", "All", {"Attribute", "Value"}, {"Attribute", "Value"}),
#"Pivoted Column" = Table.Pivot(#"Expanded All", List.Distinct(#"Expanded All"[Attribute]), "Attribute", "Value")
in
#"Pivoted Column"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group