• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

a solution need to repeat value in cell for specific count

ANKUSHRS1

Member
Hi friends,

I am seeking your help for one solution as describe in excel attachment..
 

Attachments

  • cell repeatation.xlsx
    8.6 KB · Views: 11
Hi,

Power Query Solution:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Typed = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"REPT", Int64.Type}}),
    Repeated = Table.TransformColumns(Typed, {"REPT", each List.Numbers(_,_,0), type list}),
    Expanded = Table.ExpandListColumn(Repeated, "REPT"),
    #"Removed Columns" = Table.RemoveColumns(Expanded,{"REPT"})
in
    #"Removed Columns"

Regards,
 

Attachments

  • cell repeatation.xlsx
    16.8 KB · Views: 6
Hi,

Power Query Solution:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Typed = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"REPT", Int64.Type}}),
    Repeated = Table.TransformColumns(Typed, {"REPT", each List.Numbers(_,_,0), type list}),
    Expanded = Table.ExpandListColumn(Repeated, "REPT"),
    #"Removed Columns" = Table.RemoveColumns(Expanded,{"REPT"})
in
    #"Removed Columns"

Regards,

Hi Khalid,

There is an alternative, in my eyes more readable, way via PQ...
Add a column with this formula: List.Repeat({[NAME]},[REPT])
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ChangeType = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"REPT", Int64.Type}}),
    MakeListRepeat = Table.AddColumn(ChangeType, "List", each List.Repeat({[NAME]},[REPT])),
    ExpandList = Table.ExpandListColumn(MakeListRepeat, "List"),
    RemoveOtherCols = Table.SelectColumns(ExpandList,{"List"})
in
    RemoveOtherCols
 
Back
Top