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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
CMunteanu
Frequent Visitor

Filter clients on product slicer then orders pertaining to clients

In the following scenario of a dimensional star model:

 

Customer Dimension:

CUSTOMER CUSTOMER_ID
JoeC1
PeterC2
PierreC3
PaulC4
AntonC5

 

Product Dimension:

 

PRODUCT PRODUCT_ID
APPLEP1
ORANGEP2
BANANAP3
STRAWBERRYP4

 

Order Fact Table:

ORDER CUSTOMER_IDPRODUCT_IDDATEAMOUNT
O1C1P33-11-2019234
O2C1P35-12-201812
O3C3P28-2-2009123
O4C3P312-12-2021892
O5C4P421-10-2020222
O6C4P413-7-202145
O7C4P38-8-2009125
O8C5P19-12-2011212
O9C5P26-7-2005672
O10C5P37-3-200334


The star model use relationships:

Customer.CUSTOMER_ID --> Order.CUSTOMER_ID
Product.PRODUCT_ID --> Order.PRODUCT_ID

 

We need a USER SLICER to select a product. When user selects a product, first we need to filter the customers who have ordered the selected product, and then return all orders for these clients.

For example, if user selects "ORANGE" the customers filtered should be Pierre (C3) and Anton (C5) (the model filtered 2 Customers), and the final resultset should be all orders of these customers (O3, 04, 08, 09, 010). Afterwards, we could create metrics on the filtered scenario.

How can I implement the dynamic model with this user product slicer in PowerBI Report to filter the customers (and theirs orders) who have ordered a selected product?

 

2 ACCEPTED SOLUTIONS
johnt75
Super User
Super User

You could create a measure to get the total sales value of the orders like

Sales to customers of chosen product =
VAR FilteredCustomers =
    VALUES ( 'Orders'[Customer ID] )
VAR FilteredOrders =
    CALCULATETABLE (
        VALUES ( 'Orders'[Order ID] ),
        REMOVEFILTERS ( 'Product' ),
        FilteredCustomers
    )
VAR FilteredSales =
    CALCULATE (
        SUM ( 'Orders'[Amount] ),
        REMOVEFILTERS ( 'Product' ),
        FilteredOrders
    )
RETURN
    FilteredSales

To get different metrics, like the number of orders, you would need to replace the SUM in the final calculate with whatever measure you wanted.

If you want to show the orders in a visual then you could create a measure like

Order is visible =
VAR CurrentOrder =
    SELECTEDVALUE ( 'Orders'[Order ID] )
VAR FilteredCustomers =
    VALUES ( 'Orders'[Customer ID] )
VAR FilteredOrders =
    CALCULATETABLE (
        VALUES ( 'Orders'[Order ID] ),
        REMOVEFILTERS (),
        FilteredCustomers
    )
VAR IsVisible = CurrentOrder IN FilteredOrders
RETURN
    IF ( IsVisible, 1 )

and add it as a visual level filter to only show if the value is 1

View solution in original post

v-zhangti
Community Support
Community Support

Hi, @CMunteanu 

 

You can try the following methods.

New Table:

Slicer = VALUES('Product Dimension'[PRODUCT])
ORDER = VALUES('Order Fact Table'[ORDER])

Measure:

Measure ORDER = 
Var _Product=SELECTEDVALUE('Slicer'[PRODUCT])
Var _ProductID=CALCULATETABLE(VALUES('Product Dimension'[PRODUCT_ID]),'Product Dimension'[PRODUCT]=_Product)
Var _table1=CALCULATETABLE(VALUES('Order Fact Table'[CUSTOMER_ID]),'Order Fact Table'[PRODUCT_ID]=_ProductID)
Var _table2=CALCULATETABLE(VALUES('Order Fact Table'[ORDER]),'Order Fact Table'[CUSTOMER_ID] in _table1)
Return
IF(SELECTEDVALUE('ORDER'[ORDER]) in _table2,1,0)
Measure CUSTOMER = 
Var _Product=SELECTEDVALUE('Slicer'[PRODUCT])
Var _ProductID=CALCULATETABLE(VALUES('Product Dimension'[PRODUCT_ID]),'Product Dimension'[PRODUCT]=_Product)
Var _table1=CALCULATETABLE(VALUES('Order Fact Table'[CUSTOMER_ID]),'Order Fact Table'[PRODUCT_ID]=_ProductID)
Return
IF(SELECTEDVALUE('Customer Dimension'[CUSTOMER_ID]) in _table1,1,0)

Put Measure in the filter of the view you want to filter and set it to equal 1.

 

vzhangti_0-1673848811862.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

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

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @CMunteanu 

 

You can try the following methods.

New Table:

Slicer = VALUES('Product Dimension'[PRODUCT])
ORDER = VALUES('Order Fact Table'[ORDER])

Measure:

Measure ORDER = 
Var _Product=SELECTEDVALUE('Slicer'[PRODUCT])
Var _ProductID=CALCULATETABLE(VALUES('Product Dimension'[PRODUCT_ID]),'Product Dimension'[PRODUCT]=_Product)
Var _table1=CALCULATETABLE(VALUES('Order Fact Table'[CUSTOMER_ID]),'Order Fact Table'[PRODUCT_ID]=_ProductID)
Var _table2=CALCULATETABLE(VALUES('Order Fact Table'[ORDER]),'Order Fact Table'[CUSTOMER_ID] in _table1)
Return
IF(SELECTEDVALUE('ORDER'[ORDER]) in _table2,1,0)
Measure CUSTOMER = 
Var _Product=SELECTEDVALUE('Slicer'[PRODUCT])
Var _ProductID=CALCULATETABLE(VALUES('Product Dimension'[PRODUCT_ID]),'Product Dimension'[PRODUCT]=_Product)
Var _table1=CALCULATETABLE(VALUES('Order Fact Table'[CUSTOMER_ID]),'Order Fact Table'[PRODUCT_ID]=_ProductID)
Return
IF(SELECTEDVALUE('Customer Dimension'[CUSTOMER_ID]) in _table1,1,0)

Put Measure in the filter of the view you want to filter and set it to equal 1.

 

vzhangti_0-1673848811862.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

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

FreemanZ
Super User
Super User

hi @CMunteanu 

with proper setting of the visual interactions, this can be done without any measure.

here we go:

1) plot a table/matrix visual from the columns all from the fact table

2) create a product slicer with the product[product]

3) create a customer slicer with customer[customer]

4) left click the product slicer, in the ribbon, format/edit interactions, cilck none on the table/matrix visual.

 

then it shall behave as you expect, like this:

FreemanZ_0-1673675795581.png

 

johnt75
Super User
Super User

You could create a measure to get the total sales value of the orders like

Sales to customers of chosen product =
VAR FilteredCustomers =
    VALUES ( 'Orders'[Customer ID] )
VAR FilteredOrders =
    CALCULATETABLE (
        VALUES ( 'Orders'[Order ID] ),
        REMOVEFILTERS ( 'Product' ),
        FilteredCustomers
    )
VAR FilteredSales =
    CALCULATE (
        SUM ( 'Orders'[Amount] ),
        REMOVEFILTERS ( 'Product' ),
        FilteredOrders
    )
RETURN
    FilteredSales

To get different metrics, like the number of orders, you would need to replace the SUM in the final calculate with whatever measure you wanted.

If you want to show the orders in a visual then you could create a measure like

Order is visible =
VAR CurrentOrder =
    SELECTEDVALUE ( 'Orders'[Order ID] )
VAR FilteredCustomers =
    VALUES ( 'Orders'[Customer ID] )
VAR FilteredOrders =
    CALCULATETABLE (
        VALUES ( 'Orders'[Order ID] ),
        REMOVEFILTERS (),
        FilteredCustomers
    )
VAR IsVisible = CurrentOrder IN FilteredOrders
RETURN
    IF ( IsVisible, 1 )

and add it as a visual level filter to only show if the value is 1

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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