Forum Discussion
Filter on Visual Row Context
- 5 months ago
Ashish_Mathur wrote:Hi,
Simplify your measure to
=COUNT('Table'[Data])
SamInogic wrote:Hi,
As per understanding to are attempted to achieve is to always display all names in the visual, while the Data column still shows the correct value for each row, even when a slicer filters one name.
The issue occurs because SELECTEDVALUE('Table'[Name]) is affected by the slicer context, which removes other names from the filter context. As a result, only the selected name returns data while the others appear blank.
Recommended Approach
Instead of using SELECTEDVALUE, remove the slicer filter on Name while keeping the row context from the visual.
You can modify the measure like this:
Data Measure =
CALCULATE(
COUNT('Table'[Data]),
REMOVEFILTERS('Table'[Name])
)This Works Because
REMOVEFILTERS('Table'[Name]) removes the slicer filter on the Name column.
• The row context from the table visual still applies, so each row calculates its own value.
• This allows the visual to display all names with their corresponding data, even when a slicer selection exists.Hope this helps.
Thanks!
No, these are the opposite of what I wanted to do, and the second one smells like AI.
I already mentioned what ended up working a few comments ago, but this is the DAX:
CALCULATE(COUNT('Table'[Data]), FILTER(ALL('Helper Table'),'Helper Table'[Name]=SELECTEDVALUE('Table'[Name])))The Helper Table is connected to the original table by Name and Helper Table[Name] was in the slicer.
1) Create a disconnected Name table
Name Slicer =
DISTINCT ( DimName[Name] )
Do not create a relationship from Name Slicer to your model.
2) Use fields like this
Table visual rows: DimName[Name] (the “real” name dimension that drives the rows)
Slicer: Name Slicer[Name]
3) Measure (filters data using the slicer, but keeps all rows)
Data Count :=
VAR SelNames = VALUES ( 'Name Slicer'[Name] )
RETURN
IF (
ISFILTERED ( 'Name Slicer'[Name] ),
CALCULATE (
COUNT ( Fact[Data] ),
TREATAS ( SelNames, DimName[Name] )
),
COUNT ( Fact[Data] )
)
Ashish_Mathur wrote:Hi,
Simplify your measure to
=COUNT('Table'[Data])
SamInogic wrote:Hi,
As per understanding to are attempted to achieve is to always display all names in the visual, while the Data column still shows the correct value for each row, even when a slicer filters one name.
The issue occurs because SELECTEDVALUE('Table'[Name]) is affected by the slicer context, which removes other names from the filter context. As a result, only the selected name returns data while the others appear blank.
Recommended Approach
Instead of using SELECTEDVALUE, remove the slicer filter on Name while keeping the row context from the visual.
You can modify the measure like this:
Data Measure =
CALCULATE(
COUNT('Table'[Data]),
REMOVEFILTERS('Table'[Name])
)
This Works Because
REMOVEFILTERS('Table'[Name]) removes the slicer filter on the Name column.
• The row context from the table visual still applies, so each row calculates its own value.
• This allows the visual to display all names with their corresponding data, even when a slicer selection exists.
Hope this helps.
Thanks!
No, these are the opposite of what I wanted to do, and the second one smells like AI.
I already mentioned what ended up working a few comments ago, but this is the DAX:
CALCULATE(COUNT('Table'[Data]),
FILTER(ALL('Helper Table'),'Helper Table'[Name]=SELECTEDVALUE('Table'[Name])))
The Helper Table is connected to the original table by Name and Helper Table[Name] was in the slicer.