Forum Discussion
How to Dynamically Filter Table B Based on Parameters in Table A Using DAX?
To make the filtering dynamic based on the combinations in Table C, you can modify the DAX measure to include the combinations from Table C
FilteredTableB =
VAR DistinctParameters = VALUES(TableA[parameter])
VAR FilteredB =
FILTER(
TableB,
COUNTROWS(
FILTER(
TableA,
SWITCH(
TRUE(),
TableA[parameter] = "a" && TableB[a] = TableA[value] && TableA[parameter] IN VALUES(TableC[parameter]), TRUE,
TableA[parameter] = "b" && TableB[b] = TableA[value] && TableA[parameter] IN VALUES(TableC[parameter]), TRUE,
TableA[parameter] = "c" && TableB[c] = TableA[value] && TableA[parameter] IN VALUES(TableC[parameter]), TRUE,
FALSE
)
)
) = COUNTROWS(DistinctParameters)
)
RETURN
FilteredB
This modification ensures that the filtering conditions are dynamically applied based on the combinations stored in Table C.
If my post helps, then please consider Accept it as the solution to help the other members find it more quickly. Kudos are always appreciated.
- ashi7upt2 years agoHelper I
It does help me resolve the first issue but does not address the second one.
- asadmd932 years agoAdvocate I
FilteredTableB =
VAR DistinctParameters = VALUES(TableA[parameter])
VAR FilterConditions =
ADDCOLUMNS(
DistinctParameters,
"Condition",
SWITCH(
TRUE(),
TableA[parameter] = "a", TableB[a] = TableA[value],
TableA[parameter] = "b", TableB[b] = TableA[value],
TableA[parameter] = "c", TableB[c] = TableA[value],
FALSE
)
)
VAR FilteredB =
FILTER(
TableB,
COUNTROWS(
FILTER(
FilterConditions,
[Condition]
)
) = COUNTROWS(DistinctParameters)
)
RETURN
FilteredBDistinctParameters: This variable gets the unique parameters from Table A.
FilterConditions: This variable creates a table where each row contains a condition based on the parameter. For example, if the parameter is “a”, it checks if TableB[a] equals the value in Table A.
FilteredB: This variable filters Table B by applying the conditions.
Let me know if that works.If my post helps, then please consider Accept it as the solution to help the other members find it more quickly. Kudos are always appreciated.