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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
natasha519
Helper II
Helper II

Multiple Rows based on Unique ID

I have one column with a unique ID and I want to create a new column with the following values (New, Used, Old) for each unique ID. 

 

Current Table:

Unique IDYear 
1232001
4562008

 

Desired Table:

Unique IDYearCondition
1232001New
1232001Used
1232001Old
4562008New
4562008Used
4562008Old

 

How can I acheive this in Power Query?

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @natasha519 

 

Here is my solution which may be simpler. 

 

First add a custom column from Add Column > Custom Column with the list {"New", "Used", "Old"}

vjingzhang_0-1660812489095.png

 

Then expand above custom column to New Rows. You will get the desired result. 

vjingzhang_1-1660812587248.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @natasha519 

 

Here is my solution which may be simpler. 

 

First add a custom column from Add Column > Custom Column with the list {"New", "Used", "Old"}

vjingzhang_0-1660812489095.png

 

Then expand above custom column to New Rows. You will get the desired result. 

vjingzhang_1-1660812587248.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

artpil
Resolver II
Resolver II

HI,

 

Here's one posible solution - sql like aproach. Paste the code to advanced editor.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs3LLCxNVfB0UdJRikxNLFJQitWJVjI0MgbyjQwMDMFcE1MzCNdCKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    OriginValues = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUfJLLVeK1YGwQ4tTU+Ac/xwgOxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TempId = _t, Origin = _t]),
    #"Added Custom" = Table.AddColumn(#"Promoted Headers", "TempId", each "a"),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"TempId"}, OriginValues, {"TempId"}, "Added Custom", JoinKind.LeftOuter),
    #"Expanded Added Custom" = Table.ExpandTableColumn(#"Merged Queries", "Added Custom", {"Origin"}, {"Origin"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Added Custom",{"TempId"})
in
    #"Removed Columns"

Hope this helps,

 

Artur

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.