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

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

Reply
cheid_4838
Helper IV
Helper IV

Filter Data using list or existing table

I have a table of orders where I am calculating on time performance (OTP%).  Within this table is a column called RouteIDs that I am interest in calculating OTP% for.  Instead of pulling in all 700K lines of data for the last couple of years, I would like to filter that data down to only the records that match the 81 routeids.  Is there anyway to filter based on the routeid table I created so it doesn't pull in all 700K records?  The other two options are to manually add all 81 routeids to my SQL statement or go through the routeid column in my base data and manually select each routeid I want to look at.  Thanks for your help.

1 ACCEPTED SOLUTION
Deku
Super User
Super User

Best option is to filter in your SQL statement


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

3 REPLIES 3
Chewdata
Super User
Super User

Hey! 

Does your database have a dimension table with the routes in it? 
If so,
1. create a query that gets this dimension table.

2. Filter this table to contain only the 81 routes that you want.

3. Create a Inner join between this dimension table and the Order table.

 

This approach might keep query folding from breaking, so you don't pull all 700K row into your query.

DataNinja777
Super User
Super User

Hi @cheid_4838 ,

 

You can filter your dataset in DAX by using either a calculated table or a measure. If you want to create a new table that only contains records matching the RouteIDTable, you can use the following DAX formula:

FilteredOrders = 
FILTER ( 
    Orders, 
    Orders[RouteID] IN VALUES ( RouteIDTable[RouteID] ) 
)

This will generate a table that includes only the orders where the RouteID exists in RouteIDTable. If your goal is to calculate OTP% dynamically without creating a new table, you can use a measure instead:

OTP_Percentage = 
VAR FilteredOrders =
    FILTER ( 
        Orders, 
        Orders[RouteID] IN VALUES ( RouteIDTable[RouteID] ) 
    )
VAR OnTimeOrders =
    CALCULATE ( COUNT ( Orders[OrderID] ), Orders[OnTime] = TRUE(), FilteredOrders )
VAR TotalOrders =
    CALCULATE ( COUNT ( Orders[OrderID] ), FilteredOrders )

RETURN 
    DIVIDE ( OnTimeOrders, TotalOrders, 0 )

This measure filters the Orders table based on the RouteID values found in RouteIDTable, counts the number of on-time orders, counts the total number of filtered orders, and then calculates OTP% by dividing the on-time orders by the total orders. This approach allows the calculation to update dynamically with any changes in RouteIDTable, making it efficient and scalable.

 

Best regards,

Deku
Super User
Super User

Best option is to filter in your SQL statement


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
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 Kudoed Authors