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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
seamie82
Frequent Visitor

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.

 

 

amitchandak
Super User
Super User

@seamie82 ,  Power query append.

Append : https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Or common tables https://amitchandak.medium.com/power-bi-when-i-asked-you-to-create-common-tables-a-quick-dax-solutio...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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