Forum Discussion
Table visual not filtering based on slicer
- 2 months ago
Hi ,Your % measure is breaking the natural filtering context. it’s evaluating across all reps instead of respecting the slicer. That’s why when you select Billy, the table still shows the other reps with blank Goal/Sold values.
Measures in DAX always calculate in the current filter context.
You can do some workarounds-
Use IF( HASONEVALUE() )
% Achieved =
IF (
HASONEVALUE ( Sales[Sales Rep] ),
SWITCH (
TRUE(),
[Goal] = 0 && [Sold] > 0, 1,
[Goal] > 0 && [Sold] = 0, 0,
[Goal] = 0 && [Sold] = 0, 0,
DIVIDE ( [Sold], [Goal], 0 )
)
)
2. Simplify with Direct DivisionIf your Goal and Sold are already measures scoped per rep
% Achieved = DIVIDE ( [Sold], [Goal], 0 )
Then let the slicer do the filtering .no need for the SWITCH unless you want special handling for zero case.
3.Sometimes you need to explicitly bind the measure to the row-
% Achieved =
CALCULATE (
SWITCH (
TRUE(),
[Goal] = 0 && [Sold] > 0, 1,
[Goal] > 0 && [Sold] = 0, 0,
[Goal] = 0 && [Sold] = 0, 0,
DIVIDE ( [Sold], [Goal], 0 )
),
ALLEXCEPT ( Sales, Sales[Sales Rep] )
)If this helped, please mark it as a solutions and kudos would mean a lot! It encourages contributors and keeps the community strong.
Thank you
sunita
Hi ,Your % measure is breaking the natural filtering context. it’s evaluating across all reps instead of respecting the slicer. That’s why when you select Billy, the table still shows the other reps with blank Goal/Sold values.
Measures in DAX always calculate in the current filter context.
You can do some workarounds-
Use IF( HASONEVALUE() )
% Achieved =
IF (
HASONEVALUE ( Sales[Sales Rep] ),
SWITCH (
TRUE(),
[Goal] = 0 && [Sold] > 0, 1,
[Goal] > 0 && [Sold] = 0, 0,
[Goal] = 0 && [Sold] = 0, 0,
DIVIDE ( [Sold], [Goal], 0 )
)
)
2. Simplify with Direct Division
If your Goal and Sold are already measures scoped per rep
% Achieved = DIVIDE ( [Sold], [Goal], 0 )
Then let the slicer do the filtering .no need for the SWITCH unless you want special handling for zero case.
3.Sometimes you need to explicitly bind the measure to the row-
% Achieved =
CALCULATE (
SWITCH (
TRUE(),
[Goal] = 0 && [Sold] > 0, 1,
[Goal] > 0 && [Sold] = 0, 0,
[Goal] = 0 && [Sold] = 0, 0,
DIVIDE ( [Sold], [Goal], 0 )
),
ALLEXCEPT ( Sales, Sales[Sales Rep] )
)
If this helped, please mark it as a solutions and kudos would mean a lot! It encourages contributors and keeps the community strong.
Thank you
sunita
This worked. Thanks.