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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mastone
Frequent Visitor

Not understanding AllExcept and filter concepts

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

 

model.jpg

 

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.

normal table.jpg

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

mastone_0-1678834958630.png

 

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

mastone_1-1678835149600.png

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.

 

 

1 REPLY 1
wdx223_Daniel
Super User
Super User

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.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.