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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ste_For94
Frequent Visitor

Complex filtering condition

Hi everyone

 

I have 3 tables.

 

1) components table: each component is identified by an ID and has some information attached to it

2) Activities table: each activity is performed on a single component, so for a component there's more than one activity

3)location table: it represents the territorial structure of the company, for example city>state

 

relations between tables are:

 

1)activities to components based on component ID

2)Components to location using lowest level of location (i.e components are located in a city, the location table attaches state, region and so on)

 

now what i have to do is to filter activities based on some time conditions and activity type and output an "ok"/"not ok" result, for each component. the measure that i'm building goes like this:



Component state =
CALCULATE(
IF(
CALCULATE(COUNT('activitytable'[ID]),'activity_table'[activity_type]="selected type")>=1
,
"ok",
"not ok"),
CROSSFILTER(Components[ID],'activity_table'[ComponentID],Both),
CROSSFILTER(Components[City],locationTable[City],Both),
FILTER('activity_table',
...some filter conditions...))
 
now the problem is that filters work ok and give the correct result, but if rows are duplicated for each state, if I put this measure in a table where columns are State (from location table), component (from components table), and this measure.
How can I remove duplicated values? i tried many solutions but i don't seem to find the correct one
 
2 REPLIES 2
lbendlin
Super User
Super User

what's the business reason for the bidirectional filter?  Maybe show your data model?

i substituted the  relation to a oneway relation, but i still had the problem. I solved it creating a calculated table, i don't know if it's the most efficient solution but now it works ok and it's a much simpler model.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.