Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Nino_Birdie
Frequent Visitor

Repeat rows x times for wordcloud

2020-04-01 22_59_10-Workplaz v2 - Power BI Desktop.png

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 to make a wordcloud visual with this data to make the concept bigger based on the times its repeated. The visual MUST be a wordcloud, so i cant change it.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

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.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User
Ashish_Mathur
Super User
Super User

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.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you very much! This did what i needed!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.