web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Overlapping time displ...
Power Apps
Unanswered

Overlapping time displayed in hours

(0) ShareShare
ReportReport
Posted on by

Hello

 

So I am creating an app that measures how many hours of the "core time" each employee actually covers each day.

So for the sake of discussion, let us assume this scenario:
Core time: 0900-1400. During this time, everybody must be present.

Therefore, I need to measure the clock in/out time of the employee and see how much of this time acutally overlaps this time interval. Any ideas on how to solve this?

 

Categories:
I have the same question (0)
  • Verified answer
    v-yutliu-msft Profile Picture
    on at

    Hi @Anonymous ,

    Based on your description, here's my idea:

    Create two buttons, one for online, one for offline. Make employee click the online button when he works, click the offline button when he rests. Update these time information and then filter based on time and employee name, sum up the result.

    I've made a similar test for your reference:

    1)insert two buttons, one for online one for offline.

    2)set this screen's OnVisible:  

    //create table's structure, or else you can not update later

     

    Collect(worktime,{name:Blank(),onlinetime:Blank(),offlinetime:TimeValue(Blank()),date:Blank()})

     

    //please note that you need to use offlinetime:TimeValue(Blank()), or else you can not update this field (blank() and TimeValue is not the same data type)

    set online button's OnSelect:

     

    If(IsEmpty(
     Filter(worktime,Not(name=Blank())))||
     !IsBlank(Last(Filter(worktime,Not(name=Blank()))).offlinetime),
    Collect(worktime,{name:User().FullName,email:User().Email,
    onlinetime:TimeValue(Text(Now(),DateTimeFormat.ShortTime)),
    date:Today(),
    offlinetime:TimeValue(Blank())}),
    Notify("you haven't ended working!",NotificationType.Warning))

     

    //only if the last record's offlinetime is not blank, then you could create a new record

    set offline button's OnSelect:

     

    UpdateIf(worktime,offlinetime=TimeValue(Blank())&&email=User().Email&&date=Today(),{offlinetime:TimeValue(Text(Now(),DateTimeFormat.ShortTime))})

     

    //only if the last record's offlinetime value is blank, then you could update offlinetime column 

    3)insert a label to display this employ today's worktime, set the label's Text:

     

    Sum(
     AddColumns(
     Filter(worktime,email=User().Email,
     date=Today(),
     (Time(9,0,0)<=onlinetime&&Time(14,0,0)>onlinetime)|| 
     (Time(9,0,0)<offlinetime&&Time(14,0,0)>=offlinetime)
     ),
    //filter valid record that time is from 9 to 14
     "worktime",
     If(onlinetime<Time(9,0,0)&&offlinetime>Time(9,0,0)&&offlinetime<Time(14,0,0),
     DateDiff(Time(9,0,0),offlinetime,Minutes),
     onlinetime<Time(9,0,0)&&offlinetime>Time(14,0,0),
     300,
     onlinetime>Time(9,0,0)&&onlinetime<Time(14,0,0)&&
     offlinetime>Time(9,0,0)&&offlinetime<Time(14,0,0),
     DateDiff(onlinetime,offlinetime,Minutes),
     onlinetime>Time(9,0,0)&&onlinetime<Time(15,0,0)&&offlinetime>Time(14,0,0),
     DateDiff(onlinetime,Time(14,0,0),Minutes))
     ),
    //count worktime in four situations
     worktime
     )&"minutes"

     

     

    124.PNG

     

     

     

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard