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.
tl;dr I don't understand why `ALLEXCEPT('Date', 'Date'[Date])` seems to remove the filter set by the visual, while also not removing the ones provided from the outside of it/the slicer.
I'm building a chart showing running totals for transactions. To this end, I have:
I have this mental model:
My measure starts by filtering transactions manually based on the slicer's dates. I compute the start/end dates of transactions as follows:
VAR startDate = CALCULATE(MIN('Date'[Date]), ALLEXCEPT('Date', 'Date'[Date]))
VAR endDate = MAX('Date'[Date])
This works, but I don't fully understand why.
Why does ALLEXCEPT seem to work in this case?
Hi @Ibu ,
I think you just use the MIN and MAX function as the slicer outside.
When you select the slicer, the result change dynamically.
For example, I create a sample table to explain this question.
Then I use the min and max date create a date table:
Date = CALENDAR(MIN('Transactions'[Date]), MAX('Transactions'[Date]))
Then new two measure :
MeasureVALLEXCEPT = CALCULATE(SUM(Transactions[Value]), ALLEXCEPT('Transactions','Transactions'[Date]))
MeasureVMAXANDMIN = CALCULATE(SUM('Transactions'[Value]), FILTER('Transactions', 'Transactions'[Date] <= MAX('Date'[Date]) && 'Transactions'[Date] >= MIN('Date'[Date])))
We change the slicer, we can see the MAXANDMIN is changed with the slicer, but the Allexcept is not.
Hope this helps you to understand the slicer and Allexcept function.
Here is my PBIX file.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-yinliw-msft, thanks for your reply. I believe your example demonstrates my confusion as well.
Per the docs, ALLEXCEPT is:
Removes all context filters in the table except filters that have been applied to the specified columns.
So in the MeasureVALLEXCEPT measure, it should leave the filter on Transactions[Date], yet it behaves like there is no filter at all.
As a side note, I'm now also confused why MeasureVMAXANDMIN works the way it does... given we are FILTERing within a CALCULATE, I expected there to be a context transition, meaning that MAX/MIN('Date'[Date]) would only see rows from 'Date' that match (by relationship) the Transaction's row date, and as a result the measure would always return the sum over all dates, yet it properly uses the slicer's dates (I added the table relationship for the exercise and it gives the same outcome).
@Ibu , if you are using min and max date, Using row context they will start and end date of month
If you need min selected date
minx(allselected(Date), Date[Date])
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
101 | |
79 | |
72 | |
64 |
User | Count |
---|---|
142 | |
108 | |
101 | |
81 | |
74 |