Create duplicate Rows based on cell value

cidfidou

Board Regular
Joined
Jan 19, 2009
Messages
163
Hi Guys,

I am trying to find a way to duplicate records based on another record value (in power query)

example:

Location Value
loc1 2
loc2 3

Result

loc1
loc1
loc2
loc2
loc2


Thanks in advance
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
In this video you can see how to create the following code:
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Location", type text}, {"Value", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {1..[Value]}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Value", "Custom"})
in
    #"Removed Columns
 
Upvote 0
Hi Marcel,

What an amazing answer with video on top of it!!! Thank you so much for your valuable time. You are my new hero.

I will defo spemd some time on your youtube channel
 
Last edited:
Upvote 0
Marcel -

I just saw this answer. Is there a way I could duplicate rows based on dates? I receive data with a start date for a weekly production volume. I'm having trouble figuring out in DAX how I can write a measure to show that weekly data in a pivot table - that production is happening in the next week but there's no record of it. So I'm wondering if the answer is to duplicate the weekly data in the original query.

So for a production facility with a lifespan of (say) 5 years, I would like to duplicate the rows incrementing the week on each row up until the 5 year mark. If I add production in year 2 then I would only want 4 * 52 rows of data, and so on.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,204
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top