Forum Discussion
how to apply multi dimension member filter dynamically using IN operator
- 6 years ago
Hi andymcgurty
Try the below.
Measure = VAR __view = VALUES( DIM_VIEW[View] ) RETURN CALCULATE( SUM( FACT_TB[amount] ), FACT_TB[View] IN __view )or a version with TREATAS for better performance
Measure = VAR __view = VALUES( DIM_VIEW[View] ) RETURN CALCULATE( SUM( FACT_TB[amount] ), TREATAS( __view, FACT_TB[View] ) )Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Hi andymcgurty
Try the below.
Measure =
VAR __view = VALUES( DIM_VIEW[View] )
RETURN
CALCULATE(
SUM( FACT_TB[amount] ),
FACT_TB[View] IN __view
)
or a version with TREATAS for better performance
Measure =
VAR __view = VALUES( DIM_VIEW[View] )
RETURN
CALCULATE(
SUM( FACT_TB[amount] ),
TREATAS( __view, FACT_TB[View] )
)
Mariusz
If this post helps, then please consider Accepting it as the solution.
- andymcgurty6 years agoFrequent Visitor
good work Mariusz !
TREATAS() is exactly what I was looking for and is working with context filters in my analysis.
Thanks
Andy
- andymcgurty6 years agoFrequent Visitor
Hi Mariusz
I have an issue when using this approach with time intelligence functions. It doesn't filter the correct values at the row level when the filter is selected for multiple members. It works fine if for example DIM_VIEW[View] is used as a dimension (on rows or columns) in my analysis because it can slice the values into their own buckets and know what dates are relevant for each view. While this works at the member level, the grand totals are wrong.
If all the members are selected as a filter, it aggregates the values up incorrectly without taking the individual D_VIEW[View] members into context, so the same result as the grand total is displayed.
I've managed to return the correct results in a DAX query however, I've been unable to translate this into a valid measure in my analysis that can apply the correct filtering.
Thanks
Andy