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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
catnapwat
Helper I
Helper I

Secondary data table not filtering from slicer

I have a main fact table which has a dd mmmm yy Date format, and a full Date table (with hierarchy) which I use as my date filter.

 

I also have a secondary table which has an unusual date format that I've had to massage into the Period.Formatted column shown. I've added the Month and Year columns using Power Query.

There is a relationship between the two using the Brand column. PBI will only let me use Many-to-many as there are multiple rows per month in the secondary table due to the Confidence and Type columns. Using a slicer on Brand works to filter both tables so that's something.

 

In this example, the Value column is ignoring the slicer and showing the sum all available data. In this example, I have added a further slicer on the Month column from the secondary table, which then shows the correct value.

 

How can I get the secondary table to filter correctly based on my original slicer (top-right in screenshots, showing "between" for January)? I feel like it's a relationship issue but if I move the relationship to Date instead, my test measure (Theoretical Income) is showing incorrect figures.

 

Where am I going wrong?

1 ACCEPTED SOLUTION

Solved using TreatAs()

 

GI from Forecast = CALCULATE(
SUM('GI from Forecast 2020 sheet'[Value]),
TREATAS(
SUMMARIZE(DateTable,DateTable[Year],DateTable[MonthOfYear]),
'GI from Forecast 2020 sheet'[Year],
'GI from Forecast 2020 sheet'[MonthNumber]
)
)


Referencing this guide from SQLBI.


I still have the bridge table for the client name, but the Date bridge didn't work as it created too many filter paths for my setup. However, passing the filter context to the secondary table using Treatas worked... a treat.

Thanks for the assist guys.

View solution in original post

11 REPLIES 11
amitchandak
Super User
Super User

@catnapwat , Create brand a common dimension/bridge table.

Create a date from the period on the second date. Join both tables on common dimensions and analyze

Create dimension f /bridge Table from two table - PBIX file

https://www.dropbox.com/s/op9lb78w9utdonz/Distinct%20from%20two%20Tables.pbix?dl=0

 

Try to be in

https://www.sqlbi.com/articles/the-importance-of-star-schemas-in-power-bi/

Greg_Deckler
Super User
Super User

@catnapwat - I would recommend getting rid of the direct many-to-many and putting a bridge table in place.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@Greg_Decklerthanks- having a look at these now. Is it the Brand column I should keep for the bridge?

@catnapwat Yes. Correct. Let me know if you need assistance creating the bridge table, sometimes to be safe, you want to right click both of your queries and create references. Remove everything but brand column. Append these two columns together using an Append query as new. Remove duplicates. Right-click your two intermediate queries and disable data load.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@Greg_DecklerI used the formula from @amitchandak as my main table has the Friendly Client Name as a calculated column which I couldn't use for the bridge (as it doesn't appear in Power Query), so it ended up being:

 

Bridge = DISTINCT(UNION(ALL('Timesheet Data'[FriendlyClientName]),all('GI from Forecast 2020 sheet'[Brand])))

This generated the bridge and I've added relationships as 1-to-many from the Bridge to the main and secondary tables with filter direction as Single.

 

However, the same problem occurs - and I also have all Client names from all time appearing in the slicer, rather than those with data logged in January. Some clients are old (data goes back to 2016) and don't need to appear.

 

The incorrect Value column is the main issue though.

I've set the filter direction to Both and that's solved the "all clients from all time" issue with the slicer. So it's just the Value sum being wrong now.

@catnapwat , Join are one to Many?

@amitchandak  Here's the relationships that are relevant in this case. 

 

I don't know how to get the DateTable filtering the "GI from Forecast" table and I can't connect it directly. Should it filter without a relationship?

@catnapwat - Your slicer should be based on your bridge table, right?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  my slicer is based on my central Date table. Are you saying I need two bridge tables- Brand and Date?

Solved using TreatAs()

 

GI from Forecast = CALCULATE(
SUM('GI from Forecast 2020 sheet'[Value]),
TREATAS(
SUMMARIZE(DateTable,DateTable[Year],DateTable[MonthOfYear]),
'GI from Forecast 2020 sheet'[Year],
'GI from Forecast 2020 sheet'[MonthNumber]
)
)


Referencing this guide from SQLBI.


I still have the bridge table for the client name, but the Date bridge didn't work as it created too many filter paths for my setup. However, passing the filter context to the secondary table using Treatas worked... a treat.

Thanks for the assist guys.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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