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
CHARLEA1
Frequent Visitor

Unmerging dataset

Hi there, 
I have data that is strangely structured like the following:

ColumnA   ColumnB
A                 B
B                 C

and I want to find a way to conver the data to the following:

ColumnA   ColumnB   ColumnC
A                B               C

Not quite sure where to start, but the logic should be something like if columnB value equals any row value in columnA, then columnC equals columnB value where match was made.

(Also if anyone knows what the first data reference model is referred to, that'd be great so I can investigate it more)

 

Thanks in advance!

1 ACCEPTED SOLUTION
CHARLEA1
Frequent Visitor

Following up with this thread that I have solved my issue via merging my table with the same table referencing column B as column A

View solution in original post

6 REPLIES 6
CHARLEA1
Frequent Visitor

Following up with this thread that I have solved my issue via merging my table with the same table referencing column B as column A

Anonymous
Not applicable

Hi @CHARLEA1 ,

 

You may try the pivot/unpivot feature.

Input:

vstephenmsft_9-1646639697823.png

Output:

vstephenmsft_10-1646639705885.png

 

 

1.Select two columns and click 'Unpivot Columns'.

vstephenmsft_0-1646639375658.png

 

2.Remove the Attribute column.

vstephenmsft_1-1646639424899.png

vstephenmsft_4-1646639577526.png

 

 

3.Remove duplicates.

vstephenmsft_2-1646639529284.png

vstephenmsft_5-1646639590190.png

 

 

4.Add an index column.

vstephenmsft_3-1646639563315.png

vstephenmsft_6-1646639600050.png

 

5.Pivot the Index column. Select 'Don't Aggregate' in the Aggregate Value Function.

vstephenmsft_7-1646639631469.png

vstephenmsft_8-1646639666303.png

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thingsclump
Resolver V
Resolver V

Hi @CHARLEA1 

 

Did you try using a custom function to generate column C?  This function can take values from column B and check against column A.

 

I can visualise the steps in my mind and guess it will work.

 

Thanks

www.thingsclump.com

CHARLEA1
Frequent Visitor

Also please let me know if there's an alternative way as this function seems to be very slow on my larger dataset

CHARLEA1
Frequent Visitor

Hi Nate,

using your formula as: = Table.AddColumn(#"Changed Type", "Custom", each if List.Contains(#"Changed Type"[Column1], [Column2]) then [Column2] else null)

It yields the following result:
Column1   Column2   Custom
A               B                B
B               C                null

Is there a way to pull the column2 value relevant to the row in which it matched from column1?



Anonymous
Not applicable

= Table.AddColumn(PriorStepOrTableName, "Column C", each if List.Contains(PriorStepOrTableName[Column B], [Column A]) then [Column B] else null))

 

--Nate

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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