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! Request now

Reply
Saxon202202
Helper III
Helper III

Lookupvalue in Power Query

Hi,
I have table below likt that, some of the codes are missing the description against the item. I want to create a custom column in Power Query and re-generate the description according to the item within the same table. ( I don't want to duplicate the table due to large amount of data). Sometimes the code doesn't have description in this case return blank.

Saxon202202_1-1678373932995.png

https://www.dropbox.com/scl/fi/m82rzndp35n92p7alrwtg/Power-Query.xlsx?dl=0&rlkey=ecsrehgbtrpyk55dgw3...

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Saxon202202 ,

 

For this you need to create an intermidiate step that make a group with the maximum or minimum, but has @andhiii079845 , be carefull with having more than one value for each code, in this case I'm picking up only the minimum.

 

Then you do a merge of the table with itself and you get the final result.

 

  • Group rows by code and minimum of description (I have kept your result for comparisions purposes):

MFelix_0-1678440070729.png

  • Merge the table with itself:

MFelix_1-1678440129207.png

  • Update the step on the query refering to the last step before the grouping in my case is the Changed Type:
= Table.NestedJoin(#"Changed Type", {"Code"}, #"Grouped Rows", {"Code"}, "Grouped Rows", JoinKind.LeftOuter)
  • Expand the column Description Final

MFelix_3-1678440206130.png

Complete code below and in attach file.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code", Int64.Type}, {"Description", type text}, {"Result(Description)", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Code"}, {{"Description Final", each List.Min([Description]), type nullable text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Code"}, #"Grouped Rows", {"Code"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Description Final"}, {"Description Final"})
in
    #"Expanded Grouped Rows"

 

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Saxon202202 ,

 

For this you need to create an intermidiate step that make a group with the maximum or minimum, but has @andhiii079845 , be carefull with having more than one value for each code, in this case I'm picking up only the minimum.

 

Then you do a merge of the table with itself and you get the final result.

 

  • Group rows by code and minimum of description (I have kept your result for comparisions purposes):

MFelix_0-1678440070729.png

  • Merge the table with itself:

MFelix_1-1678440129207.png

  • Update the step on the query refering to the last step before the grouping in my case is the Changed Type:
= Table.NestedJoin(#"Changed Type", {"Code"}, #"Grouped Rows", {"Code"}, "Grouped Rows", JoinKind.LeftOuter)
  • Expand the column Description Final

MFelix_3-1678440206130.png

Complete code below and in attach file.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code", Int64.Type}, {"Description", type text}, {"Result(Description)", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Code"}, {{"Description Final", each List.Min([Description]), type nullable text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Code"}, #"Grouped Rows", {"Code"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Description Final"}, {"Description Final"})
in
    #"Expanded Grouped Rows"

 

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



andhiii079845
Solution Sage
Solution Sage

The important point is if the code have everytime the same text if not blank. Not like: 123 apple , 123 appl , 133 appple. i would create a own dimensional table for the lookup values and use than the merge function. 





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

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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 Solution Authors