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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure using different tables and multiple dynamic filters

Hello PowerBI community, could you please help me with the following question?

 

I have these two tables that I want to filter using the Service Hour that I choose, for example, I'm interessed in the service hours between 7h and 9h. Then, I need to calculate how many passengers were transported divided by vehicle hours, considering only the hours I filtered.

 

These are the tables :

Shift IDStartEndShift total hoursService Hours
106:0012:0006:0002:00
206:3009:0002:3002:00
306:0008:3002:3001:30
407:0012:0005:0002:00
507:0011:0004:0002:00
608:0010:0002:0001:00

 

 

Booking IDPaxPickup timeShift IDService pax
1106:0010
2107:0021
3207:3022
4208:3032
5508:4535
6109:0041
7209:0140
8110:0040

 

 

So I created the calculated columns Service Hours and Service pax, to calculate the hours each vehicle worked and how many passengers travelled in the hours I want to filter.

 

But the thing is that I don't know how to do that using dynamic filters, where the user can choose the hours he wants to filter and that will change the calculations and give a new result. Can someone help me with that please?

 

So in this case I would have 11 passengers divided by 10,5 vehicle hours, so 1,047619 as a result.

 

I know that I can't use HASONEVALUE in calculated columns but any ideas on how to do that? I'm stucked at the moment 😞

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi lucas_pbi,

 

To achieve dynamic filter as you mentioned, you should use measure instead of calculate column like pattern below:

 

Amount =
CALCULATE (
    DISTINCTCOUNT ( Table[Shift ID] ),
    ALLSELECTED ( Table[Services hours] )
)

Regards,

Jimmy Tao

Anonymous
Not applicable

Hello,

 

With this measure I can count the different shifts but how can I calculate how many hours for each shift between 7h and 9h for example?

 

Thanks,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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