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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Leslie743
New Member

Modifying text of a duplicated row after using List.Repeat

Hello,

 

I'm a beginner power query user, trying to create unique records of buildings based on a user's desired building number input. In exampe, user has asked for X number of buildings, and identified the types of floors in that building. I used list.Repeat to duplicate all building and floor counts based on the number of each building. But now I'm stuck with indistinguishable duplicate rows.

 

Current: Building floors are duplicated but indistinguishable from each other.

Leslie743_1-1708002768975.png

Desired: Each floor of each building is duplicated WITH a unique identifier Concatenated into the Building Type. Effectively looking to create unique record for that building's floor based on how many buildings are desired from column QTY BUILDING.

 

If Building C has a Ground floor and a Typical Floor, I need those identified by Building C1, C2, C3, C4, C5, C6

Leslie743_2-1708003226808.png

 

I've looked all over and can't find an answer here. I suspect it's obvious to any experienced user. Thank you

 

Sample Data:

 

 

BuildingFloorIndexQTY Building
AUnderground11
AGround21
ATypical31
BUnderground41
BGround51
BTypical61
CGround76
CGround86
CGround96
CGround106
CGround116
CGround126
CTypical136
CTypical146
CTypical156
CTypical166
CTypical176
CTypical186
DGround192
DGround202
DTypical212
DTypical222
EGround234
EGround244
EGround254
EGround264
ETypical274
ETypical284
ETypical294
ETypical304
Site ParkingGround311
LandscapingGround321

 

Leslie743

 

 

 

1 ACCEPTED SOLUTION
mussaenda
Super User
Super User

Hi @Leslie743 ,

 

From your sample data

mussaenda_0-1708007196907.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZK9DoIwFEZfxTAz0BYojP7FxcFEnQhDA4QQTSWog28vqdpyLd/QpD3n5uttbosiWAZhcNZ1M7TD7anr8cTMKsOP2/0wJ/j06rtKXcedsHzlRcXE2aiEYBeVWr6elkujPJzN43weswhwBjgn3DXJBBIxEgkSKRISCffoDek2NxPyOI8Id0GcIcGt2JIkYebp8xjwBPCU8MnFEokMiRwIEVlx7B7N4qCGS6fbaRvC/fK90vW9Uv1/xffDl28=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Building = _t, Floor = _t, Index = _t, #"QTY Building" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Building", type text}, {"Floor", type text}, {"Index", Int64.Type}, {"QTY Building", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Building", "Floor"}, {{"Count", each _, type table [Building=nullable text, Floor=nullable text, Index=nullable number, QTY Building=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count], "Bldg Count", 1, 1)),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Index", "QTY Building", "Bldg Count"}, {"Index", "QTY Building", "Bldg Count"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Custom", each [Building] & Number.ToText([Bldg Count]))
in
    #"Added Custom1"

 

View solution in original post

4 REPLIES 4
mussaenda
Super User
Super User

Hi @Leslie743 ,

 

From your sample data

mussaenda_0-1708007196907.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZK9DoIwFEZfxTAz0BYojP7FxcFEnQhDA4QQTSWog28vqdpyLd/QpD3n5uttbosiWAZhcNZ1M7TD7anr8cTMKsOP2/0wJ/j06rtKXcedsHzlRcXE2aiEYBeVWr6elkujPJzN43weswhwBjgn3DXJBBIxEgkSKRISCffoDek2NxPyOI8Id0GcIcGt2JIkYebp8xjwBPCU8MnFEokMiRwIEVlx7B7N4qCGS6fbaRvC/fK90vW9Uv1/xffDl28=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Building = _t, Floor = _t, Index = _t, #"QTY Building" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Building", type text}, {"Floor", type text}, {"Index", Int64.Type}, {"QTY Building", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Building", "Floor"}, {{"Count", each _, type table [Building=nullable text, Floor=nullable text, Index=nullable number, QTY Building=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count], "Bldg Count", 1, 1)),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Index", "QTY Building", "Bldg Count"}, {"Index", "QTY Building", "Bldg Count"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Custom", each [Building] & Number.ToText([Bldg Count]))
in
    #"Added Custom1"

 

Thank you @mussaenda - the Source = Table.FromRows (Json...) would that instead by referenced to my last step? Apologies, not familiar with what that large address would be or if it exists because I put the sample data inside the message instead of as a file.

Thank you, worked perfectly once I referenced my own data

Hi @Leslie743 ,

 

For the source, you need to change it according to your own source.

You can start doing the steps from grouped rows to achieve your desired result

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors