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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
steigelbill
Frequent Visitor

Multi Level Count and Filter within single day

Screen Shot 2017-06-20 at 4.14.07 PM.png

So, I am trying to use PowerBI analysis to figure out employee throughput. The data set has date & Time, User, Order # and zone.  So I need to count the number of orders done in a zone and divide it by the duration they were in that zone.

 

I can do that!  My problem is calculating when a person changes between zones.

 

Currently to determine duration when someone is in a zone all day, I subtract the start time from end time (and multiply by 24): 

INT Start Time = CALCULATE(MIN(ActivityTracking[Time]),Filter(All(ActivityTracking),ActivityTracking[Zone]="INT"),Filter(All(ActivityTracking),ActivityTracking[User]=Users[User]))

INT End Time = CALCULATE(MAX(ActivityTracking[Time]),Filter(All(ActivityTracking),ActivityTracking[Zone]="INT"),Filter(All(ActivityTracking),ActivityTracking[User]=Users[User]))

 

What I would need to do is sum up the duration of multiple instances of being in a zone, and have that total be the divisor.

 

Any ideas would be appreciated.

2 REPLIES 2
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @steigelbill

 

We can add a row to evaluate the duration per user per zone. Then we can sum up the durations of many instances.

 

DuringPerUserPerZone =
 (
    CALCULATE (
        MAX ( ActivityTracking[Date Created] ),
        FILTER (
            ActivityTracking,
            ActivityTracking[User] = EARLIER ( ActivityTracking[User] )
                && ActivityTracking[Zone] = EARLIER ( ActivityTracking[Zone] )
                && ActivityTracking[Date Created].[Date]
                    = EARLIER ( ActivityTracking[Date Created].[Date] )
        )
    )
        - CALCULATE (
            MIN ( ActivityTracking[Date Created] ),
            FILTER (
                ActivityTracking,
                ActivityTracking[User] = EARLIER ( ActivityTracking[User] )
                    && ActivityTracking[Zone] = EARLIER ( ActivityTracking[Zone] )
                    && ActivityTracking[Date Created].[Date]
                        = EARLIER ( ActivityTracking[Date Created].[Date] )
            )
        )
)
    * 24

 

DuringPerUserPerDay =
CALCULATE (
    SUM ( ActivityTracking[DuringPerUserPerZone] ),
    FILTER (
        ActivityTracking,
        ActivityTracking[User] = EARLIER ( ActivityTracking[User] )
            && ActivityTracking[Date Created].[Date]
                = EARLIER ( ActivityTracking[Date Created].[Date] )
    )
)

 

NumberOfOrders =
CALCULATE (
    COUNT ( ActivityTracking[LPN] ),
    FILTER (
        ActivityTracking,
        ActivityTracking[User] = EARLIER ( ActivityTracking[User] )
            && ActivityTracking[Date Created].[Date]
                = EARLIER ( ActivityTracking[Date Created].[Date] )
    )
)
Result =
[DuringPerUserPerDay] / [NumberOfOrders]

Or we can use a measure with the new column.

MesureResult =
SUM ( ActivityTracking[DuringPerUserPerZone] ) / COUNT ( ActivityTracking[LPN] )

Multi Level Count and Filter within single day .jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

 

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @steigelbill,

 

Could you please mark the proper post as answer if it worked? More about this topic, please feel free to post here.

Best Regards!
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.