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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
daniel_t_93_
Frequent Visitor

Help with merging values on a specific column in a new table

Hi, 

 

I have the following dataset (simplified)

 

IDValueStep 1Step 2Step 3
1AA  
1B B 
1C  C
2AA  
3AA  
3D D 
3G  G
4AA  
4F F 

 

Step 1, 2 and 3 are derived from the value in the column 'value', using IF statements.

 

What I want is, in a new table, the following:

 

IDStep 1Step 2Step 3
1ABC
2A  
3ADG
4AF 

 

I tried this using a LOOKUPVALUE function, but that obviously doesn't work since it matches on multiple values (also the blanks). I also tried a CALCULATE, FIRSTNONBLANK and FILTER combination, but that also didn't work.

 

As you can see, step 2 and 3 can take up different values, or have no value at all. This happens when a person didn't get to that step at all. 

 

Anyone has some advice on how to achieve this? 

 

Thanks in advance!

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Value", type text}, {"Step 1", type text}, {"Step 2", type text}, {"Step 3", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Value"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"ID"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

Hope this helps.

Ashish_Mathur_0-1717631503533.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Value", type text}, {"Step 1", type text}, {"Step 2", type text}, {"Step 3", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Value"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"ID"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

Hope this helps.

Ashish_Mathur_0-1717631503533.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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