Forum Discussion
Power BI Dynamic Filter/Slicer
- 3 months ago
Hey PrasadSwamy007,
1) Create a disconnected slicer table
// DAX SlicerTable = DISTINCT('Table'[Source])2) Create this measure
Custom Sales = VAR SelectedSource = SELECTEDVALUE('SlicerTable'[Source]) RETURN CALCULATE( SUM('Table'[Sales]), FILTER( 'Table', 'Table'[Source] = SelectedSource || (SelectedSource = "XYZ" && 'Table'[Sub-Source] = "pack") ) )Key Results:
- For ABC / DEF - filters normally by Source
- For XYZ - also pulls in rows where Sub-Source = "pack"
- Disconnected table ensures the slicer doesn't auto-filter your fact table
Hope this helps!
Best,
Harshit
- 3 months ago
Hi,
As per our understanding your requirement, you need a custom slicer behavior where:
- Normally → filter by Source
- But when XYZ is selected → also include rows where Sub-Source = "pack" (even if Source ≠ XYZ)
So expected results:
- ABC → 10 + 20 + 30 = 60
- XYZ → 40 + 50 + 60 + pack(10 + 30) = 190
- DEF → 70 + 80 + 90 = 240
Recommended Solution (Measure-Based)
Create a disconnected slicer table:
Slicer_Source =
DISTINCT(TableName[Source])Use this table in your slicer.
Then create a measure:
Sales Dynamic =
VAR SelectedSource =
SELECTEDVALUE(Slicer_Source[Source])
RETURN
CALCULATE(
SUM(TableName[Sales]),
FILTER(
ALL(TableName),
TableName[Source] = SelectedSource
||
(
SelectedSource = "XYZ"
&& TableName[Sub-Source] = "pack"
)
)
)How it works
For normal selections (ABC, DEF):
Source = SelectedSource
works normally.
For XYZ:
It additionally includes:
Sub-Source = "pack"
So:
XYZ = 40 + 50 + 60 + 10 + 30 = 190
Setup Steps
- Create Disconnected Slicer Table
- Add it to slicer
- Create the Sales Dynamic measure
- Use measure in cards/charts/tables
Note:
Do not use your original Source column directly in slicer, otherwise Power BI’s normal filtering will interfere.Use the disconnected slicer table only.
This approach gives you fully dynamic custom filter logic
Hope this helps.
Thanks!
Handle this in a measure:
Filtered Sales =
VAR SelectedSource = SELECTEDVALUE('SlicerTable'[Source])
RETURN
CALCULATE(
SUM('Table'[Sales]),
FILTER(
'Table',
'Table'[Source] = SelectedSource
|| (SelectedSource = "XYZ" && 'Table'[Sub-Source] = "pack")
)
)
Use a disconnected slicer table with distinct Source values. Do not connect it to your fact table via a relationship.
- PrasadSwamy0073 months agoRegular VisitorThank you kedar
Sorry I forgot to mention the matrix has this measure : Display_final = if(ISINSCOPE('Diagonal Lookup2027'[Year]),[Display_2026],[total_2025_2026])
The sales column was an example, The above measure has been used in matrrix Values and that has to be filtered. Also the measure that you have provided has to be used in Slicer or the matrix visual (set it = 1)?