Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
andymcgurty
Frequent Visitor

how to apply multi dimension member filter dynamically using IN operator

I'm trying to dynamically apply a filter statement in DAX using the IN operator. By passing in a string of members to filter on. 

 

In my scenario the fact table and DIM table do not have a relationship. After applying a context filter on DIM_VIEW[View] I want the selected members to be used to filter the fact table. Without relating the tables is this possible in DAX?

 

The DAX code below works when I filter one member however, it doesn't like multiple selections. The concatenatex() line correctly generates the member list but the IN operation does accept a dynamic input if there's more than one selection. 


   VAR onemember = "View1"
   VAR multiplemembers = """" & CONCATENATEX ( VALUES ( DIM_VIEW[View] ), [View], """" & ",""" ) & """"  

    RETURN
    
        VALUE (
           
               CALCULATE (
                    SUM ( FACT_TB, [amount] )
              
                               )


                   // one member - works
                   //,FACT_TB[View] IN {onemember} 
                   // multiple members - does not work
                   ,FACT_TB[View] IN {multiplemembers} 
                 )
                    

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

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.

 

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

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 @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

 

 

 

 

good work @Mariusz !

 

TREATAS() is exactly what I was looking for and is working with context filters in my analysis. 

 

Thanks

 

Andy

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.