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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Dynamic ALLEXCEPT based on selected slicers.

I have a measure with ALLEXCEPT DAX command for count the quantity of orders per equipment category. But it is static, but in order to have a real count depending of the selection in the slicers in need to transform that measure into a dynamic count.

 

For example:

Category: Trucks Quantity of orders per Category: 10
Truck 110
Truck 210
Truck 310
Truck 410
Category: MixersQuantity of orders per Category: 15
Mixer 115
Mixer 215

 

But in this example if the user select another date or another country, the table is going to have the same values because i'm using the following DAX command:


Quantity of orders per Category =
CALCULATE(COUNT(Table[Order]),ALLEXCEPT(Table,Table[Category]))

Any sugestion to convert this dax into a dynamic one.

Thank you so much!
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
This should work

Quantity of orders per Category = 
VAR SelectedDates = ALLSELECTED ( 'Table'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' ), 
        REMOVEFILTERS ( ),
        VALUES ( 'Table'[Category] ),
        SelectedDates
    )  

 

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @Anonymous 
This should work

Quantity of orders per Category = 
VAR SelectedDates = ALLSELECTED ( 'Table'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' ), 
        REMOVEFILTERS ( ),
        VALUES ( 'Table'[Category] ),
        SelectedDates
    )  

 

Anonymous
Not applicable

Hi @tamerj1 that's what I was looking for, thank you so much! 👍 

Anonymous
Not applicable

Hi @littlemojopuppy here is some sample data, as you can see the last column have the total quantity of orders by category, but in the second table if I select a different date, the results must change. 

 

CountryDateOrderEquipmentCategoryQ orders per Category
US01-02-224868Kiln2Kilns18
Colombia02-02-224906Kiln2Kilns18
Colombia03-02-224598Kiln3Kilns18
Brazil04-02-224532Mixer 1Mixers9
Colombia05-02-224626Truck 3Trucks21
Colombia06-02-224797Mixer 1Mixers9
US07-02-224817Kiln3Kilns18
US08-02-224557Truck 4Trucks21
Canada09-02-224923Truck 3Trucks21
Brazil10-02-224773Truck 3Trucks21
US11-02-224807Truck 2Trucks21
Mexico12-02-224654Kiln1Kilns18
Colombia13-02-224661Kiln3Kilns18
Canada14-02-224987Mixer 1Mixers9
Colombia15-02-224965Truck 4Trucks21
US16-02-224737Truck 1Trucks21
Colombia17-02-224938Truck 1Trucks21
US18-02-224938Truck 1Trucks21
Brazil19-02-224821Truck 2Trucks21
Mexico20-02-224966Truck 1Trucks21
Brazil21-02-224752Truck 4Trucks21
Mexico22-02-224827Kiln3Kilns18
US23-02-224931Truck 4Trucks21
Mexico24-02-224677Kiln1Kilns18
US25-02-224768Truck 3Trucks21
Colombia26-02-224640Truck 1Trucks21
Brazil27-02-224747Truck 4Trucks21
Colombia28-02-224638Mixer 1Mixers9
Canada01-03-224928Kiln2Kilns18
Mexico02-03-224583Kiln1Kilns18
Brazil03-03-224935Truck 2Trucks21
Canada04-03-224848Kiln1Kilns18
Colombia05-03-224566Mixer 1Mixers9
Mexico06-03-224802Truck 2Trucks21
Colombia07-03-224640Mixer 2Mixers9
Canada08-03-224603Truck 3Trucks21
Canada09-03-224786Kiln2Kilns18
Canada10-03-224752Mixer 1Mixers9
Mexico11-03-224724Mixer 2Mixers9
US12-03-224738Kiln3Kilns18
Brazil13-03-224961Kiln1Kilns18
Mexico14-03-224688Kiln2Kilns18
Canada15-03-224798Mixer 1Mixers9
Colombia16-03-224786Kiln1Kilns18
Colombia17-03-224586Truck 1Trucks21
Brazil18-03-224643Kiln2Kilns18
Mexico19-03-224614Kiln1Kilns18
Colombia20-03-224743Truck 4Trucks21

 

Filtered only by dates in March

 

CountryDateOrderEquipmentCategoryQ orders per Category
Canada01-03-224928Kiln2Kilns10
Mexico02-03-224583Kiln1Kilns10
Brazil03-03-224935Truck 2Trucks5
Canada04-03-224848Kiln1Kilns10
Colombia05-03-224566Mixer 1Mixers5
Mexico06-03-224802Truck 2Trucks5
Colombia07-03-224640Mixer 2Mixers5
Canada08-03-224603Truck 3Trucks5
Canada09-03-224786Kiln2Kilns10
Canada10-03-224752Mixer 1Mixers5
Mexico11-03-224724Mixer 2Mixers5
US12-03-224738Kiln3Kilns10
Brazil13-03-224961Kiln1Kilns10
Mexico14-03-224688Kiln2Kilns10
Canada15-03-224798Mixer 1Mixers5
Colombia16-03-224786Kiln1Kilns10
Colombia17-03-224586Truck 1Trucks5
Brazil18-03-224643Kiln2Kilns10
Mexico19-03-224614Kiln1Kilns10
Colombia20-03-224743Truck 4Trucks5
tamerj1
Super User
Super User

Hi @Anonymous 

You can add the date column and the country column inside ALLEXCEPT

Alternatively, you can use  

CALCULATE(COUNT(Table[Order]),REMOVEFILTERS(Table[Equipment]))

littlemojopuppy
Community Champion
Community Champion

Hi @Anonymous the reason it's not changing is because ALLEXCEPT() only includes Category as a field to ignore filters.

 

But I'm thinking you might be overcomplicating this...have you tried just simply COUNT(Table[Order]) as your measure?  That would take into account filter context for Category, Date, Country, or whatever other filters are applied.  If you did, what happened?

Anonymous
Not applicable

Thanks for your answer @littlemojopuppy 
If I just make a simply COUNT(Table[Order]), the measure is going to count the amount of orders by equipment but not by category. In the example the table is going to be something like:


Category: Trucks Quantity of orders per Category: 10
Truck 14
Truck 22
Truck 31
Truck 43
Category: MixersQuantity of orders per Category: 15
Mixer 19
Mixer 26

 

Thanks

@Anonymous can you provide some sample data to work with?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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