Forum Discussion
Nino_Birdie
6 years agoFrequent Visitor
Repeat rows x times for wordcloud
So i have this table with concepts, the id and score . I need to repeat for example the first row with the concept and the id, 4 times, the second just 1, the third 4, and so on. Because i need...
- 6 years ago
Hi,
This M code does the job
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTK0BBImSrE60UrBMK4hmOuCKuuKyg2BcY3B3EgY1wjM9UM1ygPIMrNAqPaC8yHyTnC+mVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Concepts = _t, ID = _t, Score = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Concepts", type text}, {"ID", Int64.Type}, {"Score", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {1..[Score]}), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Score", "Custom"}) in #"Removed Columns"Hope this helps.
Ashish_Mathur
Super User
6 years agoHi,
This M code does the job
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTK0BBImSrE60UrBMK4hmOuCKuuKyg2BcY3B3EgY1wjM9UM1ygPIMrNAqPaC8yHyTnC+mVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Concepts = _t, ID = _t, Score = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Concepts", type text}, {"ID", Int64.Type}, {"Score", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {1..[Score]}),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Score", "Custom"})
in
#"Removed Columns"
Hope this helps.
- Nino_Birdie6 years agoFrequent Visitor
Thank you very much! This did what i needed!
- Ashish_Mathur6 years ago
Super User
You are welcome.