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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
shashanm
Frequent Visitor

Power BI Dynamic filtering

I need to filter my Order table based on the Conditions table. The catch is that my conditions table can have any number of rows.

I have my tables in the below format - 

Condition SetBillTo_CodeShipper_CodeReceiver_Code
C1B1, B2  
C2 S1, S3R3
C3B3, B4S3, S4R2, R3, R4

 

Order NoBillToShipperReceiver
1B4S4R4
2B2S3R2
3B2S3R1
4B4S1R3
5B3S4R1
6B5S3R3
7B1S3R5
8B2S3R6
9B4S5R6
10B3S3R2

 

The consitions need to be applied in the following way - 

1. For each row in the conditions table - it's an AND condition between the 3 codes. 

2. Then we UNION the results of each row

 

For the above table I have, my results would be -

1. For C1 - 2, 3, 7, 8 

2. For C2 - 4, 6

3. For C3 - 10

Final results - 2, 3, 4, 6, 7, 8, 10

 

The equivalent SQL in this case would be - 

SELECT OrderNo FROM Orders WHERE

(BillTo IN (B1, B2))   OR        --C1

(Shipper IN (S1, S3) AND Receiver IN (R3)) OR     --C2

(BillTo IN (B3, B4) AND Shipper IN (S3, S4) AND Receiver IN (R2, R3, R4))   --C3

 

I need to be able to loop through the conditions table as the number of condiiton sets can change dynamically.

 

Can someone please help with the implementation in Power BI?

 

1 ACCEPTED SOLUTION
onurbmiguel_
Power Participant
Power Participant

Hi @shashanm 

Please analise the following file. 

 

Conditions in orders.pbix

 

onurbmiguel__0-1681921135892.png

 

Look with details at the new "Condition Table" , i have made some changes !! 

 

 

Best regards

Bruno Costa | Power Participant

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍

You can also check out BI4ALL's website and our data solutions!

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


View solution in original post

1 REPLY 1
onurbmiguel_
Power Participant
Power Participant

Hi @shashanm 

Please analise the following file. 

 

Conditions in orders.pbix

 

onurbmiguel__0-1681921135892.png

 

Look with details at the new "Condition Table" , i have made some changes !! 

 

 

Best regards

Bruno Costa | Power Participant

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍

You can also check out BI4ALL's website and our data solutions!

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


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.