adding new rows based on column value

khabouri

New Member
Joined
Sep 17, 2017
Messages
1
hi there
well yesterday i had add power query for my Microsoft excel 2010, so i am really new to this. so my question is that power query can add columns, but no rows? unless if we add column then we pivot it, but even adding columns has to be manual, i mean i dont know yet how to make an automatic formula.
in my scenario i have the following data

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Description[/TD]
[TD]type[/TD]
[TD]cat.[/TD]
[TD]number[/TD]
[/TR]
[TR]
[TD]A-001[/TD]
[TD]alpha[/TD]
[TD]a[/TD]
[TD]cat.1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]C-003[/TD]
[TD]delta[/TD]
[TD]a[/TD]
[TD]cat.2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]C-004[/TD]
[TD]beta[/TD]
[TD]c[/TD]
[TD]cat.1[/TD]
[TD]5[/TD]
[/TR]
</tbody>[/TABLE]

now the "number" represents how many time is data copied for the represented row.
so what i am trying to achieve first is as follow:

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Description[/TD]
[TD]type[/TD]
[TD]cat.[/TD]
[TD]number[/TD]
[/TR]
[TR]
[TD]A-001[/TD]
[TD]alpha[/TD]
[TD]a[/TD]
[TD]cat.1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]C-003[/TD]
[TD]delta[/TD]
[TD]a[/TD]
[TD]cat.2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]C-003[/TD]
[TD]delta[/TD]
[TD]a[/TD]
[TD]cat.2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]C-004[/TD]
[TD]beta[/TD]
[TD]c[/TD]
[TD]cat.1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]C-004[/TD]
[TD]beta[/TD]
[TD]c[/TD]
[TD]cat.1[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]C-004[/TD]
[TD]beta[/TD]
[TD]c[/TD]
[TD]cat.1[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]C-004[/TD]
[TD]beta[/TD]
[TD]c[/TD]
[TD]cat.1[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]C-004[/TD]
[TD]beta[/TD]
[TD]c[/TD]
[TD]cat.1[/TD]
[TD]5[/TD]
[/TR]
</tbody>[/TABLE]

so is there a way to go to power query advance and add a formula to make this automatically?

thank you in advance and best regards
Khabouri
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
After 1 day experience with Power Query it is way too soon to draw conclusions about what would be (im)possible.
Please bear in mind that Power Query is built on a complete programming language ("M"), so just assume for now that anything is possible until proven otherwise.

I created table Data in Excel and the query below for your requirements. You can create a new blank query, go into the Advanced Editor and replace the default code with the code below.

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Description", type text}, {"type", type text}, {"cat.", type text}, {"number", Int64.Type}}),
    TransformedToLists = Table.TransformColumns(#"Changed Type", {{"number", each {1.._}, type {Int64.Type}}}),
    #"Expanded number" = Table.ExpandListColumn(TransformedToLists, "number")
in
    #"Expanded number"
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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