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

Join three tables where no fields match (full outer?)

I have three tables, example:

  3 tables.png

 

Table 1 shows the normal weekly quantity allowed on for a particular origin-destination combination.  e.g., UK to DE normally we are only allowed to send 8 units.  

 

Table 2 shows that for some weeks we might have an exception.  Example IE to BE for weeks 52 and 01 (christmas holidays!) we are not allowed to send any units (ZERO units).  Table 2 ONLY shows exception weeks - not all weeks.

 

Table 3 shows the week range of the total data set. i.e. ALL weeks

 

Previously I was just multiplying the QTY by the number of weeks to get a total, but the new exceptions (table 2) means that I can't do that any more.  It is also important that I am able to show this by week as well as by total, as it goes into a lvely line chart over time.  So I am looking for a way to join these tables together to give me something like this, where all data in table 1 is shown against all weeks:


desiredoutput.png

 

(which is horrible proliferation, I know, but my actual Table 1 is only 2K rows so if I proliferate even for a full year of 52 weeks it's still not that bad!)

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @dapperscavenger ,
I would start with table3 and add a custom column where you reference table1.
That will return everything from table1 for each week.
Then join table2 to it based on "From", "To", and "week".

Then add a custom column with the condition that if the value of the expansion from table2 is null, then take the expansion from table1, else take expansion from table2.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

2 REPLIES 2
ImkeF
Super User
Super User

Hi @dapperscavenger ,
I would start with table3 and add a custom column where you reference table1.
That will return everything from table1 for each week.
Then join table2 to it based on "From", "To", and "week".

Then add a custom column with the condition that if the value of the expansion from table2 is null, then take the expansion from table1, else take expansion from table2.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Brilliant, yes, it was just that first step I was stuck on. I didn't know you could reference another column like that

 

Had to look up how to write it but it was fairly straightforward:  =#"table_name_here"

Thank you

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