Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi Power BI Brains!
I need a bit of help please, I've been stuck on this problem and don't fully understand why it's happening. I've got a dataset that contains a Calendar table and a Sales Detail fact table that have a one to many join between them, single direction from Calendar to the Sales table.
I've created a table of explicit measures: a set of measures for the current year and a set for the previous year (based on the dates in my Calendar table where each calendar date has a YOY date in the financial year which does not align with the standard gregorian calendar).
The DateSelections table that I created for my pre-defined periods has a one to many relationship filtering both ways to the Calendar table and has *no* relationship to the fact table.
If I select let's say "Week to Date" on my dropdown using DateSelections then it goes and filters my Calendar table which then correctly filters my Sales Fact table and returns the correct Sales Unit Value. Here's the weird part... Sales Unit Value LY goes blank! If I create a slicer that has any field in from the Calendar table and I use that to filter the sales fact talbe, Sales Unit Value LY is correctly returned.
If DateSelections filters Calendar and Calendar filters Sales fact then why is the Sales Unit Value LY metric not populating at all when I make a selection in DateSelections?
I am quite confused, I suspect it's to do with not being able to pass a filter context onto a second table or something? I tried adding an inactive relationship between DateSelections and the Sales Fact and then use USERELATIONSHIP but the problem persisted.
Any thoughts on what I'm doing wrong??
Solved! Go to Solution.
You need to explicitly remove the filters from the date selection table, the automatic removal of filters only applies to the date table itself, not the expanded table
Sales Unit Value LY =
VAR _MaxDate =
CALCULATE ( MAX ( 'Calendar by Calendar Date'[YOY Financial Calendar Date] ) )
VAR _MinDate =
CALCULATE ( MIN ( 'Calendar by Calendar Date'[YOY Financial Calendar Date] ) )
RETURN
CALCULATE (
[Sales Unit Value],
ALL ( 'Sales Daily Detail' ),
REMOVEFILTERS ( 'Date Selections' ),
'Calendar by Calendar Date'[Date] >= _MinDate
&& 'Calendar by Calendar Date'[Date] <= _MaxDate
)
In your measure you are placing a filter on the date column in the fact table, you need to put the filter on the date table. The reason that the measure is returning blank is that there is a filter on the date table for dates this year, which passes to the fact table, and then a filter on the fact table for dates last year. those 2 filters combined will result in an empty table, so the measure returns blank.
By putting the filter on the date table, when you add the filter for last year DAX will automatically replace any existing filters rather than combining them, as long as your date table is properly marked as a date table.
Hi johnt75,
So if I understand your suggestion then the LY value should have the following DAX:
You've still got the filter on the fact table. Try
Sales Unit Value LY =
VAR _MaxDate =
CALCULATE ( MAX ( 'Calendar by Calendar Date'[YOY Financial Calendar Date] ) )
VAR _MinDate =
CALCULATE ( MIN ( 'Calendar by Calendar Date'[YOY Financial Calendar Date] ) )
RETURN
CALCULATE (
[Sales Unit Value],
ALL ( 'Sales Daily Detail' ),
'Calendar by Calendar Date'[Date] >= _MinDate
&& 'Calendar by Calendar Date'[Date] <= _MaxDate
)
I've popped in the formula you were suggesting, wihtout selecting anything from the slicer that shows the Type field from DateSelections table I get values, same as before so that's working however....
Then I select WTD for instance and the LY value disappears still. I know that my fact table contains that data for last year for this week, if you manually query the data for those dates, the values are there. And the formula does return the correct LY value if I use any slicers that point to my Calendar table and not the DateSelection table.
Change the measure to store the result of the final CALCULATE in a variable and then you can check that the dates being returned are what you expect by having the measure return first the min date and then change it again to return the max date.
I tested this early on in my testing process and the dates returned are correct.
You need to explicitly remove the filters from the date selection table, the automatic removal of filters only applies to the date table itself, not the expanded table
Sales Unit Value LY =
VAR _MaxDate =
CALCULATE ( MAX ( 'Calendar by Calendar Date'[YOY Financial Calendar Date] ) )
VAR _MinDate =
CALCULATE ( MIN ( 'Calendar by Calendar Date'[YOY Financial Calendar Date] ) )
RETURN
CALCULATE (
[Sales Unit Value],
ALL ( 'Sales Daily Detail' ),
REMOVEFILTERS ( 'Date Selections' ),
'Calendar by Calendar Date'[Date] >= _MinDate
&& 'Calendar by Calendar Date'[Date] <= _MaxDate
)
Thank you, using the REMOVEFILTERS actually resolved it!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
10 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
13 | |
12 | |
11 | |
8 |