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

Linking Tables without losing unmatched records

Hi all,

I have two tables, one containing Actual data for Month and Customer Code and one containing Target values for Month and Customer Code. 

 

Cattura.PNG

 

 

 

 

 

 

 

 

I am trying with no luck to join them in a way that keeps all of the codes and links the target only for the matching ones.
I have created a key that concatenates code and month BUT

  • The following is the result I get if I set the key-relationship to filter from Target to Actual.
     

    Output 1.PNG

  • This is the result when filtering from Actual to Target
    output2.PNG

    Below is the desired output where all codes have the matching target:

 

output.PNG

 

As an additional note, actuals table is very heavy (about 4 millions) so a heavy-computation solution could not work. 

Link to the example file

Thank you in advance for your help!

Kind Regards

 

Jenna 😘

3 REPLIES 3
PaulDBrown
Community Champion
Community Champion

@Jackopoe 

 

The recommended best pratice is to set up your model with dimension or lookup tables to use in slicers, filters or measures. These lookup tables allow you to establish the relevant filter context for equivalent values in your tables.

Here is an example of your model with a "Code" lookup table linked to both your actuals and target tables through "code" as the  common field:,

Model.JPG

 In order to set it up this way, there are a few methods. Let me walk you through one of these.

Go into Power Query and:

1) Select your "code" column in your either of your tables (Actuals or Target), right click on it and select "Add as new query" (towards the bottom of the list)

1 Add new Q.png

 

2) Convert this query to a table (and give it a name)

2 Convert table.png

 

3) to ensure that you have all possible values for code, repeat this excercise with the other table.

4) now append both these tables into a new one.Append.png

This creates a new query/table with all the possible values for "Code"  from both your tables.

5) remove duplicate rows from this new table and give it a name (I've called it Code)Remove duplicates (2).png

6) since you will not be needing the two tables you created previously, you can disable loading them into the model by right clicking on each and de-selecting "Enable load".

 

7) Carry out this process again for you Month columns in both your tables to create a new query with the unique values for month.

 

Load your queries into the model, and set up the one-to-many relationships between your newly created tables and your Actuals and Target tables by linking the corresponding columns. Your model should lool like this:

Wmodel.png

 

Now you can set up your visuals using the fields from your lookup tables as your rows

 

And you get the following:

result.JPG

 

Edit: Something I haven't metioned is that it is also highly recomended to have a Calendar/Date table with unique dates covering the range of dates in you model (and use it as a lookup table in slicers, measures or filter for anything to do with dates). In "99%" of models, this is the way to do it (unless a model has no dates!)

In the example I've provided, I've created the "Month" lookup table; it is much better to create a Date table instead of the month lookup table.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Tad17
Solution Sage
Solution Sage

Hey @Jackopoe 

 

Can you share the measures and data relationships going into these tables? It looks like there may be an issue with the Target.

 

Also, you will need to select "Show Items with no Data " to get the desired output: https://docs.microsoft.com/en-us/power-bi/desktop-show-items-no-data

Hi Tad17, I have posted a link to the example file.

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.