Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I have table as below:
WordQuantity
AAA | 3 |
BBB | 2 |
EEE | 4 |
I need to convert it to the below (repeat every line base on the number on the quntity column)
AAA | 3 |
AAA | 3 |
AAA | 3 |
BBB | 2 |
BBB | 2 |
EEE | 4 |
EEE | 4 |
EEE | 4 |
EEE | 4 |
Thanks!
Nir.
Solved! Go to Solution.
You can add a Custom Column and then expand it to new rows
={1..[Quantity]}
The delete this custom column
Final code/ File attached as well
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnR0VNJRMlaK1YlWcnJyArKNwGxXV1cg20QpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Word = _t, Quantity = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Word", type text}, {"Quantity", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {1..[Quantity]}), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Custom"}) in #"Removed Columns"
You can add a Custom Column and then expand it to new rows
={1..[Quantity]}
The delete this custom column
Final code/ File attached as well
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnR0VNJRMlaK1YlWcnJyArKNwGxXV1cg20QpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Word = _t, Quantity = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Word", type text}, {"Quantity", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {1..[Quantity]}), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Custom"}) in #"Removed Columns"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |