cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PapithaSekar
Helper II
Helper II

for loop

Is it possible to do the calculation like in normal loop.

my condition is to calculate remaining holiday

employee will enter to total holiday i had in last year and this year and i have to calculate total available holiday and when he applies leave then total available holiday should be one day minus.

 

Holiday_lastyear(HLY)

Holiday_thisyear(HTY)

Total_available_holiday(TAH) = HLY+ HTY

leave = TAH - 1

 my doubt is if i use the above formula it will work correctly when he applies first leave, after that TAH remains same and leave will be calculated from that.

 

Please help me to calculate and update the values.

For(leave = 0; leave >=TAH;leave++)

{

current_Leave = TAH -1;

TAH = Current_leave;

}

 

4 REPLIES 4
Rahber
Super User II
Super User II
v-bofeng-msft
Community Support
Community Support

Hi @PapithaSekar :

Do you want the value of TAH to be corresponding to -1 after executing "leave = TAH-1"?

I think this does not necessarily need to be implemented through a loop.The following code can directly achieve this requirement.

 

Ser(leave,TAH - 1);set(TAH,leave)

 

If you insist on using loops, I suggest you use the timer control.

I set the following Timer controls exactly according to your loop statement (if you need to adjust it, you can refer to the method I use)

Add a timer control:

Duration:

 

1000/*loop in 1s(I am here just to make the presentation more clear, you can shorten the loop interval)*/

 

OnSelect:

 

Set(leave,0)

 

OnTimerEnd:

 

Set(current_Leave,TAH -1);Set(TAH,current_Leave);Set(leave,leave+1);

 

Repeat:

 

If(leave>=TAH,false,true)

 

I assume ATH=10

11.gif

Best Regards,

Bof

 

Thank you. I will try the first formula and update you. Timer control doesn't fit in my scenario. Am creating time registration app so employee will update if they take leave during working days. Daily they will registering time. Leave registration is one part of it. 

 

Hi @PapithaSekar :

Is your problem solved? Do you still need help?

If you have found a solution, could you mark it as a solution so that more people can see it.

Best Regards,

Bof

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (4,412)