Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I am struggling to understand why my formula using AllExcept is not working as expected. My slimmed down model looks like the following:
Facilities.Id=> Surveys.FacilityId
Areas.Id => Surveys.AreasId
Facilities.Id => Areas.FacilityId
I am trying to get a count of all Surveys with all filters removed except the facility filter. So essentially, it's a count within the facility regardless of the other filter contexts.
My expectation was to be able to do
CALCULATE(COUNTROWS(Surveys), ALLEXCEPT(Surveys, Surveys[FacilityId]))
However, this yields a count of ALL survey records, and not just the surveys with the FacilityId filter applied. In addition, if I add that measure into my data table, it expands the currently selected facilities to all facilities (i.e. it essentially removes the facility filter on the data table).
My data table without the expression above and just a normal count looks like this and has 10 rows.
Adding in the measure with the formula above yields the table below with thousands of rows and a count of 1.4 million (when it should be 9678).
In trying to figure this out, I found that the following formula yields exactly what I want.
Total Facility Count = VAR SelectedFacilities = ALLSELECTED( Surveys[FacilityId], Surveys[SVSTATUS] )
RETURN
CALCULATE (
COUNTROWS ( Surveys ),
REMOVEFILTERS ( ),
VALUES ( Surveys[FacilityId] ),
SelectedFacilities
)
and
BUT I want to understand why the AllExcept version is behaving like it is. I am new to PowerBI and DAX so I am sure there is some fundamental concept that I am not picking up on. Any help explaining why the second query works as opposed to the first would be greatly appreciated.
from your snapshoot, can not what's the outsider filters.
for the DAX code, ALLEXCEPT(table,....), will get a table withe all columns and it will expand to all the dim table related, and remove the filters.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |