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

Accepted Solutions
Highlighted

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
Highlighted
Super User IV
Super User IV

@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!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Super User IV
Super User IV

@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/



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted

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

Highlighted

@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!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted

@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.

Highlighted

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.

Highlighted

@catnapwat , Join are one to Many?



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted

@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?

Highlighted

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


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors