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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.