Reply
SnoekL
Helper II
Helper II

2 Step Filter on dimension approach

Hi, I'm not sure if this can be resolved using dax but I need to filter my data in a simple matrix or table visual and it feels easy but I'm struggling with it. I need to filter all orders that contain a selected product but than show all products for those orders. 

 

Simplefied example:

SnoekL_0-1705505053949.png

I want to be able to have a filter on the dimension product and the result should be the table at the end which is showing the som by product for all orders that contain the selected product. Can anyone help me with this please?

1 ACCEPTED SOLUTION
v-nuoc-msft
Community Support
Community Support

Hi @SnoekL 

 

For your question, here is the method I provided:

 

I used the data you provided

 

vnuocmsft_0-1705565616460.png

 

“FACT Orderlines”

vnuocmsft_1-1705565632861.png

 

Create a measure. Query all orders that contain the selected product.

Select_Product-Amount = 
    var select_product = 
        IF(
            ISFILTERED('ProductDim'[Name]), 
            VALUES('ProductDim'[ID]), 
            BLANK()
        )
    var select_product_amount = 
        SUMX(
            FILTER(
                'FACT Orderlines', 
                CALCULATE(
                    CONTAINS(
                        'FACT Orderlines', 
                        'FACT Orderlines'[ProductID],
                        select_product
                    ), 
                    ALLEXCEPT(
                        'FACT Orderlines', 
                        'FACT Orderlines'[OrderID] 
                        )
                )
            ), 
            'FACT Orderlines'[Amount]
        )
RETURN select_product_amount

vnuocmsft_2-1705565829270.png

 

Create a measure. Group and sum the product.

Product_amount = 
    SUMX(
        FILTER(
            ALL('FACT Orderlines'), 
            'FACT Orderlines'[ProductID] = MAX('FACT Orderlines'[ProductID])
            ),
        [Select_Product-Amount]
    )

 

Here is the result.

vnuocmsft_3-1705565970870.png

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

2 REPLIES 2
SnoekL
Helper II
Helper II

Thanks that works great 🙂

v-nuoc-msft
Community Support
Community Support

Hi @SnoekL 

 

For your question, here is the method I provided:

 

I used the data you provided

 

vnuocmsft_0-1705565616460.png

 

“FACT Orderlines”

vnuocmsft_1-1705565632861.png

 

Create a measure. Query all orders that contain the selected product.

Select_Product-Amount = 
    var select_product = 
        IF(
            ISFILTERED('ProductDim'[Name]), 
            VALUES('ProductDim'[ID]), 
            BLANK()
        )
    var select_product_amount = 
        SUMX(
            FILTER(
                'FACT Orderlines', 
                CALCULATE(
                    CONTAINS(
                        'FACT Orderlines', 
                        'FACT Orderlines'[ProductID],
                        select_product
                    ), 
                    ALLEXCEPT(
                        'FACT Orderlines', 
                        'FACT Orderlines'[OrderID] 
                        )
                )
            ), 
            'FACT Orderlines'[Amount]
        )
RETURN select_product_amount

vnuocmsft_2-1705565829270.png

 

Create a measure. Group and sum the product.

Product_amount = 
    SUMX(
        FILTER(
            ALL('FACT Orderlines'), 
            'FACT Orderlines'[ProductID] = MAX('FACT Orderlines'[ProductID])
            ),
        [Select_Product-Amount]
    )

 

Here is the result.

vnuocmsft_3-1705565970870.png

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)