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

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.

Reply
Anonymous
Not applicable

How do you Insert / Add / Duplicate Rows based on cell contents in PowerQuery?

Hi I am very new to PowerQuery and am trying to get assistance navigating M code.


I do not want to create a new column/table. The data set contains over 500K rows of information. 

 

All I want to do is create two additional rows (3 in total), where every [Description] = 12 CT Variety Pack. I would love to also change the [Description] in each of the two additional rows to = 6 CT, Organic and 6 CT, Non-GMO. I would also like the original row remain in place and to be left alone.

I would also like the [Total] to be divided by half in the 2 new rows. 

 

Thank you so much for taking the time to read and respond to this.


Here is an example of what I would like the final product to look like. 

                                           

1 REPLY 1
dax
Community Support
Community Support

Hi spar101,

If you want to add new row in table by PowerQuery, you could try to use expression like below

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIE4sjUYqVYnWglIyDbCcaPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Dimension = _t, #"Dimension Name" = _t, #"From Data Source" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dimension", Int64.Type}}),
    Custom1 = Table.InsertRows(#"Changed Type",2, { [Dimension = 3, Dimension Name = "Custom Row", From Data Source = "No"] })
in
    Custom1

You could refer to Table.InsertRows for details.

By the way, are these three row are specific rows? Summarize? Or other feature? You could use above expression, if rows are less.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors