Forum Discussion
Kaitra
5 years agoFrequent Visitor
Table transformation based on dynamic entries
Hello everybody, i am having a problem which I cannot solve by myself. I have a table that looks like this: Date as month Company Name Score Category March A 5 x March B 4 ...
- 5 years ago
Hey Kaitra ,
that should be possible.
Mark the column [Date as month] and select pivot amd chose the score column for the values:
Afterwards you should have the desired result:
Here the full M-Code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k0sSs5Q0lFyBGJTIK5QitVBiDoBsQlc1LGgKDMHqtYYiCsx1JpiiDoDsRGGuTDRSgxzDTHUwmyrUoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date as month" = _t, #"Company Name" = _t, Score = _t, Category = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date as month", type text}, {"Company Name", type text}, {"Score", Int64.Type}, {"Category", type text}}), #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#"Date as month"]), "Date as month", "Score", List.Sum) in #"Pivoted Column"If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
selimovd
5 years agoMost Valuable Professional
Hey Kaitra ,
that should be possible.
Mark the column [Date as month] and select pivot amd chose the score column for the values:
Afterwards you should have the desired result:
Here the full M-Code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k0sSs5Q0lFyBGJTIK5QitVBiDoBsQlc1LGgKDMHqtYYiCsx1JpiiDoDsRGGuTDRSgxzDTHUwmyrUoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date as month" = _t, #"Company Name" = _t, Score = _t, Category = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date as month", type text}, {"Company Name", type text}, {"Score", Int64.Type}, {"Category", type text}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#"Date as month"]), "Date as month", "Score", List.Sum)
in
#"Pivoted Column"
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic