cancel
Showing results for
Did you mean:
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.

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

{

current_Leave = TAH -1;

TAH = Current_leave;

}

4 REPLIES 4
Super User II
Community Support

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)

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

Best Regards,

Bof

Helper II

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.

Community Support

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

Announcements

#### Check it out!

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

#### Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

#### 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)