cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
liam34
Frequent Visitor

need help. How to count all days per request on my vacation apps powerapps?

i building a vacation apps using the leave request template availble from powerapps 
im using global variable, i need to get the sum of days per leave request by user.

 

if you could provide it will be appreciate.

 

thanks,

 

liam

8 REPLIES 8
365-Assist
Power Participant
Power Participant

I see the solution will require 2 parts:

 

1 - For each record in the LeaveCollection you will have to add a field that calculates the number of work days between StartDate and EndDate. I found this article that may help with this DateDiff calculation. https://powerapps.microsoft.com/de-de/blog/excluding-weekends-and-holidays-in-date-differences-in-po...

 

2 - Then you need to create a calculated field to a form that adds all the results for each Employee from the calculation  in Step 1 above. 

v-xida-msft
Community Support
Community Support

Hi @liam34 ,

Could you please share a bit more about your scenario?

Do you want to count the all days per leave request by user within your app?

 

If all Leave Requests submitted from your app are stored in LeaveCollection or a Table, I think the ForAll function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

Add a Label within your app, set the Text property to following:

Sum(
    ForAll(
          LaeaveCollection,    // If you store the Leave request in other data source, please replace with the data source here
          DateDiff(StartDate, EndDate, Days)
    ),
    Value
)

Above formula would calculate the total days for all requests submitted from your app.

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

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

hi kris thanks for the reply my scenario is im building a vacation/leave request using CDS variable, own entity and may use some of the global variable using custom enity.

my task is to is gettin the datediff or or how many days per request and get the total for all by the current user which will be in "Days" count or numeric.

hope this will clear a bit.

 

thanks 

 

hi this seems a little bit tricky im just a newbie on powerapps can you provide more clearer instruction. thanks appreciate.

im using my own cds and some global variable make field on it to connect on my cds.

Hi @liam34 ,

Could you please share a bit more about your scenario?

Do you use a CDS Entity as data source to store the Leave Request submitted from your app?

 

If you use CDS Entity to store your leave request records submitted from your app, please make sure the data structure of your CDS Entity is the same as that in the LeaveCollection (built-in collection to store the leave request record) as below:

1.JPG

 

I assume that your CDS Entity has same data structure as above, and you want to count request days per request based on current login user, please consider take a try with the following workaround:

Add a Data Table control in your app, set the Items property to following:

AddColumns(
           Filter('CDSEntity',Requester = User().Email),
           "TotalRequestDays",
           DateDiff(StartDate, EndDate, Days)
)

Then you could see the total request days for each leave request (submitted from your app) by current login user. The 'TotalRequestDays' column would store the toal Days value for each submiited leave request.

 

Best regards,

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

big thanks i got it i just need another thing, i just cant show the days per "request". i attached a pictures of the codes you sent me it works but now as exactly. and the screen im working on

 

now i need is how many days in a request so i can put on my vacation details.

realy appreciate 🙂

Sorry attempting to delete my reply without success

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (1,976)