cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

Being able to see week history of hours clocked in

Hello there! I have an application where employee's can clock in their hours. 

Here I have a gallery that shows all of the hours that have been filled in. https://gyazo.com/9435779174cd33473e6ecb9db778c01f

Here is the code of the gallery:

 

If(
    gblIsAdmin;
    UrenRegistratie;
    SortByColumns(
        Filter(
            UrenRegistratie;
            Datum = Text(
                Today ();
                "dd/mm/yyyyy"
            ) And varcurrentuser = Werknemer
        );
        "TijdBegin"
    )
)

 

This gallerij takes only the tickets of the day of today & where the varcurrentuser (the logged in user his fullname) is equal to Werknemer (The one that filled in a ticket, also full name). 

Whenever gblIsAdmin = true, you can see all of the tickets. 

I have to have a button, if you click on it, it should give you the results for the past month & also check if varcurrentuser is equal to Werknemer. I think we can use almost the same code as I have already used. How can I do this?  

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

@TimoMigchielsen ,

You need to get down to some basic debugging here are pull this apart - does this work?

With(
    {URegAdmin:UrenRegistratie},
    SortByColumns(
       Filter(
          URegAdmin,
          DateDiff( 
             DateValue(Datum),       
             Today(),
             Days
          )< vTime 
       ),
       "TijdBegin"
   )
)

I need to remind you that the With() statement is doing nothing more than removing the delegation warning - if you have more than 2,000 records in UrenRegistratie, the second statement will only provide the first 2,000 records (the first one produces up to 2,000 records after filtering).
Before we go any further, can you please confirm the number of records in your list and also if the newest 2,000 will get what you need - if so, you would do something like this. NOTE - I have free-typed this and I am only showing you the structure, so watch commas and brackets.

Search(
   Sort(
      With(
         {
            UReg:
            Filter(
               UrenRegistratie,
               Werknemer = varcurrentuser
            ),
            URegAdmin:
            Sort(            
               UrenRegistratie,
               ID,
               Descending
            )
         },
         SortByColumns( 
            If(
               gblIsAdmin,
               Filter(
                  URegAdmin,
                  DateDiff( 
                     DateValue(Datum),       
                     Today(),
                     Days
                  )< vTime 
               ),
               Filter(
                  UReg,
                  DateDiff( 
                     DateValue(Datum),       
                     Today(),
                     Days
                  )< vTime 
               )
            ),
            "TijdBegin"
         )
      ), 
      Datum,
      Descending
   ), 
   TextSearchBox1.Text,
   "Title",
   "Status",
   "Werknemer",
   "CodeWerknemer",
   "Uurcode",
   "Bon"
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

32 REPLIES 32
Highlighted
Super User III
Super User III

Hi @TimoMigchielsen ,

If(
    gblIsAdmin;
    UrenRegistratie;
    SortByColumns(
        Filter(
            UrenRegistratie;
            IsToday(Datum) &&
            Werknemer = varcurrentuser
        );
        "TijdBegin"
    )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted

Thank you for your answer @WarrenBelz 

Are you maybe able to explain what you did exactly? I have also changed it from 1 week to a month, I want to be able to see a month back when you press on a button (Must also be possible for gblIsAdmin (needs to show ALL tickets in that month)

Highlighted

@TimoMigchielsen ,

I actually corrected your code on the current day, but reading it further, if you want the past month

If(
    gblIsAdmin;
    UrenRegistratie;
    SortByColumns(
        Filter(
            UrenRegistratie;
            DateDiff( 
               Datum;          
               Today();
               Days
            ) <30 &&
            Werknemer = varcurrentuser
        );
        "TijdBegin"
    )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted

@WarrenBelz Thank you for your help but it's not what I need. Please read my question again. It only needs to show the results for the past 30 days when you click on a button. Otherwise it just shows todays result. The reason I have done it like that is because there is a difference between dates (dd/mm/yyyy  & mm/dd/yyyy) 

If possible I'd also like to have a button that filters on 7 days. So we have 2 buttons, 1 for a month and 1 for a week.

Highlighted

@TimoMigchielsen ,

But where is the button name or the code you have attempted on it?

Highlighted

The name of the button is = WeekView
The name of the second button is = MonthView

I have no tried any code yet because I do not know how to do it @WarrenBelz 

Highlighted

@TimoMigchielsen ,

You have been posting on this forum for a quite a while -  I am surprised that you do not even attempt code, but ask others to write it for you - this forum is called Learn for a reason. I see you have re-posted the same question here.

I will leave it for others to answer and have closed this post.

Highlighted

@WarrenBelz I do attempt to get it done. I work with this 40 hours a week but some things are out of my reach. And what you linked is not the same question. I am going to turn it not the solution

"but ask others to write it for you" isn't this what this forum is for though? 🤣

Highlighted

@TimoMigchielsen ,

I closed it so you could continue on the other post. If you want to keep this one, then that one needs to be closed.

The more you post on this forum, the more it is reasonable to view this as a partnership to which you contribute. We are mostly volunteers spending our time trying to help people and I have seen people that I have helped grow from beginners to competent Power Apps operators. They have done this by attempting the code, looking at the corrections and understanding them. I am happy to help people, but like to see they are actually learning something.

What you need is this: - 

On your Monthly Button put

UpdateContext({vTime:32})

Your Weekly button

UpdateContext({vTime:8})

You will then need a Daily button

UpdateContext({vTime:1})

then this code

If(
   gblIsAdmin;
   UrenRegistratie;
   SortByColumns(
      Filter(
         UrenRegistratie;
         DateDiff( 
            Datum;          
            Today();
            Days
         )< vTime &&
         Werknemer = varcurrentuser
      );
      "TijdBegin"
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (2,395)