The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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:
Solved! Go to Solution.
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" )
)
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:
Count =
CALCULATE (
DISTINCTCOUNT ( Students_SM1[ID_KEY] ),
FILTER (
ALL ( Students_SM1 ),
[STUDENT_STATUS] = SELECTEDVALUE ( Students_SM1[STUDENT_STATUS] )
)
)
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.
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!