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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
EuanP007
New Member

Identify orders to exclude in one table to filter another in Power BI desktop.

Hi I'm hoping someone could provide some advice or give a working solution to a problem I'm having with Power BI.

I need to allow a user to select a Sales Category or multiple sales categories via a Slicer that then will for the identification of all order_IDs for the Sales Category.  I then need to filter the customers Table so that it excludes any of the order_ID's that the slicer selection has identified.

 

 Below is a small example dataset with the two tables , which replicates the data structure and expected result example

 

Customers Table with Order_ID, Customer_ID & Customer_Name

Customer_IDOrder_IDCustomer_Name
C34T234556Homer Simpson
C87T984845Darth Vader
C23T643968James T Kirk
C94T735396Eleven

 

Sales table with Order_ID, Sales_Category & Price. 

Order_IDSales_CategoryPrice
T234556Free Pen £             -  
T234556Keyboards £     15.00
T234556Mouse Pads £       2.50
T234556Mice £     20.00
T984845Mice £     10.00
T984845Mouse Pads £       5.00
T984845Screens £  100.00
T643968Keyboards £     50.00
T735396Free Pen £             -  
T735396Mouse Pads £       5.00

 

 

Result_Required is an example of the result table required in Power BI

Any order where Free Pens is selected in a slicer needs to be identified and then filtered from the Customers Table. The slicer will be used to select other sales items and multiple sales items, so needs to be dynamic.

Customer_IdOrder_IDCustomer_Name
C87T984845Darth Vader
C23T643968James T Kirk

 

Many thanks

1 ACCEPTED SOLUTION
Ahmed-Elfeel
Resolver III
Resolver III

Hi @EuanP007,

I hope you are doing well😄

 

Ok here is the DAX Solution (DAX measures)🚀

At First you should Create a Measure to Identify Orders to Exclude (Step 1)

Orders to Exclude Count = 
CALCULATE(
    DISTINCTCOUNT(Sales[Order_ID]),
    ALLSELECTED(Sales[Sales_Category])
)

 

Create a Measure for Filtered Customers (Step 2)

Filtered Customer Count = 
CALCULATE(
    DISTINCTCOUNT(Customers[Customer_ID]),
    FILTER(
        Customers,
        NOT(Customers[Order_ID] IN 
            CALCULATETABLE(
                VALUES(Sales[Order_ID]),
                ALLSELECTED(Sales[Sales_Category])
            )
        )
    )
)

 

Create a Dynamic Table using DAX (Step 3)

Dynamic Filtered Customers = 
VAR ExcludedOrders = 
    CALCULATETABLE(
        VALUES(Sales[Order_ID]),
        ALLSELECTED(Sales[Sales_Category])
    )
RETURN
FILTER(
    Customers,
    NOT(Customers[Order_ID] IN ExcludedOrders)
)

 

Let me know if it worked I have another 2 solution you can do 😀

 

If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-agajavelly
Community Support
Community Support

Hi @EuanP007 ,

I hope the response provided helped in resolving the issue. If you still have any questions, please let us know we are happy to address.

Thanks,
Akhil.

v-agajavelly
Community Support
Community Support

Hi @EuanP007 ,

Circling back again, were you able to try out Ahmed’s solution with the calculated table and Dynamic Filtered Customers? If it didn’t fully resolve the issue, could you share what result you’re seeing so we can help fine-tune it further.

Thanks,
Akhil.


v-agajavelly
Community Support
Community Support

Hi @EuanP007 ,

Just checking in were you able to test the solution that Ahmed shared with the calculated table and Dynamic Filtered Customers? It should exclude the orders tied to the selected categories and display the remaining customers. Let us know if it worked as expected or if you ran into any issues.

Thanks,
Akhil.

v-agajavelly
Community Support
Community Support

Hi @EuanP007 ,

Thanks @Ahmed-Elfeel for jumping in with a detailed solution. The approach you’ve shared especially the calculated table with Dynamic Filtered Customers already covers the requirement exactly orders tied to the selected categories get excluded, and the remaining customers are shown.

@EuanP007 could you please give this a try in your report and confirm if it works for you?

Thanks,
Akhil.

Ahmed-Elfeel
Resolver III
Resolver III

Hi @EuanP007,

I hope you are doing well😄

 

Ok here is the DAX Solution (DAX measures)🚀

At First you should Create a Measure to Identify Orders to Exclude (Step 1)

Orders to Exclude Count = 
CALCULATE(
    DISTINCTCOUNT(Sales[Order_ID]),
    ALLSELECTED(Sales[Sales_Category])
)

 

Create a Measure for Filtered Customers (Step 2)

Filtered Customer Count = 
CALCULATE(
    DISTINCTCOUNT(Customers[Customer_ID]),
    FILTER(
        Customers,
        NOT(Customers[Order_ID] IN 
            CALCULATETABLE(
                VALUES(Sales[Order_ID]),
                ALLSELECTED(Sales[Sales_Category])
            )
        )
    )
)

 

Create a Dynamic Table using DAX (Step 3)

Dynamic Filtered Customers = 
VAR ExcludedOrders = 
    CALCULATETABLE(
        VALUES(Sales[Order_ID]),
        ALLSELECTED(Sales[Sales_Category])
    )
RETURN
FILTER(
    Customers,
    NOT(Customers[Order_ID] IN ExcludedOrders)
)

 

Let me know if it worked I have another 2 solution you can do 😀

 

If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors