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
cliang
Frequent Visitor

Card doesn't change when slicing

Hello,

 

I have a few cards that are using DAX formulas to filter values but when I slice the data using different slicers, sometimes it changes and sometimes it doesn't. I've tried two different measures.

 

Here is the first:

 

Count of ID_KEY for Active student =
CALCULATE(
    DISTINCTCOUNT('Students_SM1'[ID_KEY]),
    'Students_SM1'[STUDENT_STATUS] IN { "Active student" }
)
 
Here is the second:
 
Count Active = CALCULATE(DISTINCTCOUNT(Students_SM1[ID_KEY]), Students_SM1[STUDENT_STATUS] = "Active student")
 
I'm slicing the STUDENT_STATUS attribute but it doesn't change the card. Any help would be great!
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@cliang 

When you use Students_SM1[STUDENT_STATUS] = "Active student" in a calcualte that overrides any filter you apply to the Students_SM1[STUDENT_STATUS] column so that is why your slicer is not working.  If you want to count only the actives and not show anything if you turn off actives you need to include a KEEPFILTERS like this:

Count Active =
CALCULATE (
    DISTINCTCOUNT ( Students_SM1[ID_KEY] ),
    KEEPFILTERS ( Students_SM1[STUDENT_STATUS] = "Active Student" )
)

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @cliang 

 

This is already a fixed count and does not change as the slicer changes.

Count Active = CALCULATE(DISTINCTCOUNT(Students_SM1[ID_KEY]), Students_SM1[STUDENT_STATUS] = "Active student")

Maybe you can try the following.
Sample data:

vzhangti_2-1663919539007.png

Count = 
CALCULATE (
    DISTINCTCOUNT ( Students_SM1[ID_KEY] ),
    FILTER (
        ALL ( Students_SM1 ),
        [STUDENT_STATUS] = SELECTEDVALUE ( Students_SM1[STUDENT_STATUS] )
    )
)

vzhangti_0-1663919284830.pngvzhangti_1-1663919296726.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

jdbuchanan71
Super User
Super User

@cliang 

When you use Students_SM1[STUDENT_STATUS] = "Active student" in a calcualte that overrides any filter you apply to the Students_SM1[STUDENT_STATUS] column so that is why your slicer is not working.  If you want to count only the actives and not show anything if you turn off actives you need to include a KEEPFILTERS like this:

Count Active =
CALCULATE (
    DISTINCTCOUNT ( Students_SM1[ID_KEY] ),
    KEEPFILTERS ( Students_SM1[STUDENT_STATUS] = "Active Student" )
)

This worked! Thank you so much!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors