cancel
Showing results for 
Search instead for 
Did you mean: 
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
Super User
Super User

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
Winner of T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Find out who won the T-Shirt Design Challenge and the top 3 finalists.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

Power BI Dev Camp Session 32

Ted's Dev Camp - March 30, 2023

In this session, we'll examine important design issues and decisions that arise when developing with Power BI embedding.

Top Solution Authors