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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
seamie82
New Member

Best approach to combining data with some matching rows and different columns

Hi, 

What is the best approach to combining data from two tables (Actuals and Forecast in the example below), so both the Actual and Forecast field are available in the resulting table when some rows match and some don't.

seamie82_1-1664448583110.png

Merging using a full outer join results in the following:

seamie82_0-1664448546228.png

Would you then just create a new name field something like this:  

seamie82_2-1664449172757.png

Taking the value from Name if it's not null or from Forecasts.Name if Name is null.

Resulting in this:

seamie82_3-1664449264919.png

Which can obviosuly then be tidied up:

seamie82_4-1664449331563.png

Is there a better way of achieving the same thing?

 

3 REPLIES 3
AntonioM
Solution Sage
Solution Sage

Hi @seamie82 ,

 

The way I would approach this is to unpivot both the Actual and Forecast columns, append the two tables together and then rename 'Attribute' to Type.

 

AntonioM_1-1664452280701.png

AntonioM_2-1664452288526.png

 

That would give you this table:

 

AntonioM_0-1664452256016.png

 

Then in your measures you can use

CALCULATE ( [measure] , Table[Type] = "Actual" )

or

CALCULATE ( [measure] , Table[Type] = "Forecast" )

to use the two different sets of values.

 

 

Thanks, I read this already: https://radacad.com/append-vs-merge-in-power-bi-and-power-query

If you used append though would you do something like this?

Adding a descriptive column to each source and then appending:

seamie82_0-1664452620435.png

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors