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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Priya_N999
New Member

How to Get respective row data based on a matched criteria from a different row using Power Query

Hi All, I am fairly new to Power Query platform and am looking for a way to get data displayed in a cell based on matched criteria . The belwo table will give a bettr insight on my requirements. 

 

Available datasExpected Result - Get all members names displayed based on the  data in member1 Id and Member2 Id
IdsMember1 IdMember2 IdNames 
1A01  Humpty 
1A02  Dumpty 
1A03  Jack 
1A04  Jill 
1A501A011A02 Humpty/Dumpty
1A601A031A04 Jack/Jill
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Priya_N999 ,

Please try the following steps.

1. Merge Queries:

[Member1 Id]--[Ids]

vcgaomsft_1-1670828524448.png

[Member2 Id]--[Ids]

2. Expand Names:

vcgaomsft_2-1670828682055.png

3. Add custom column:

vcgaomsft_3-1670828804534.png

4. Remove the [Name.1] and [Name.2] columns.

vcgaomsft_4-1670828888910.png

5. Steps:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMnQ0MFTSUYIgj9LcgpJKpVgdsLgRXNwFRdwYLu6VmJwNEzVBiGbm5EBFTQ2AfKgVMBMhMmZQGWMIBdYdGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ids = _t, #"Member1 Id" = _t, #"Member2 Id" = _t, Names = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ids", type text}, {"Member1 Id", type text}, {"Member2 Id", type text}, {"Names", type text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Member1 Id"}, #"Changed Type", {"Ids"}, "Changed Type", JoinKind.LeftOuter),
    #"Merged Queries1" = Table.NestedJoin(#"Merged Queries", {"Member2 Id"}, #"Merged Queries", {"Ids"}, "Merged Queries", JoinKind.LeftOuter),
    #"Expanded Changed Type" = Table.ExpandTableColumn(#"Merged Queries1", "Changed Type", {"Names"}, {"Names.1"}),
    #"Expanded Merged Queries" = Table.ExpandTableColumn(#"Expanded Changed Type", "Merged Queries", {"Names"}, {"Names.2"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Merged Queries", "Custom", each [Names.1] & "/" & [Names.2]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Names.1", "Names.2"}),
    #"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Ids", Order.Ascending}})
in
    #"Sorted Rows"

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

7 REPLIES 7
Manoj_Nair
Solution Supplier
Solution Supplier

@Priya_N999 - Try this PBIX file. Power BI file 

 

Please don't hesitate to give kudos to useful posts and mark solution as accepted. Many Thanks 

pratyashasamal
Memorable Member
Memorable Member

Hi @Priya_N999 ,
Can you share a clear raw dataset and how the desired dataset show look like .
Thanks ,
Pratyasha Samal.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





The table seems to have got mis-allginde in my original query. I hope the below helps.

Priya_N999_0-1670570646900.png

 

Anonymous
Not applicable

Hi @Priya_N999 ,

Please try the following steps.

1. Merge Queries:

[Member1 Id]--[Ids]

vcgaomsft_1-1670828524448.png

[Member2 Id]--[Ids]

2. Expand Names:

vcgaomsft_2-1670828682055.png

3. Add custom column:

vcgaomsft_3-1670828804534.png

4. Remove the [Name.1] and [Name.2] columns.

vcgaomsft_4-1670828888910.png

5. Steps:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMnQ0MFTSUYIgj9LcgpJKpVgdsLgRXNwFRdwYLu6VmJwNEzVBiGbm5EBFTQ2AfKgVMBMhMmZQGWMIBdYdGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ids = _t, #"Member1 Id" = _t, #"Member2 Id" = _t, Names = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ids", type text}, {"Member1 Id", type text}, {"Member2 Id", type text}, {"Names", type text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Member1 Id"}, #"Changed Type", {"Ids"}, "Changed Type", JoinKind.LeftOuter),
    #"Merged Queries1" = Table.NestedJoin(#"Merged Queries", {"Member2 Id"}, #"Merged Queries", {"Ids"}, "Merged Queries", JoinKind.LeftOuter),
    #"Expanded Changed Type" = Table.ExpandTableColumn(#"Merged Queries1", "Changed Type", {"Names"}, {"Names.1"}),
    #"Expanded Merged Queries" = Table.ExpandTableColumn(#"Expanded Changed Type", "Merged Queries", {"Names"}, {"Names.2"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Merged Queries", "Custom", each [Names.1] & "/" & [Names.2]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Names.1", "Names.2"}),
    #"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Ids", Order.Ascending}})
in
    #"Sorted Rows"

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

This helped. Thank you so much for  your time in understanding my requirement and providing the step by step solution along with the screenshots. Appreciate it.

Thank you everyone else who took time to look into this query and help me find a solution.

@Priya_N999 - have you checked the attached PBIX  file? your misalignment is already considered in the power query and the result shown as desired. 

image.jpg

Desired Output 

*mis-alligned

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Kudoed Authors