Hi,
I'm hoping someone could point me in the right direction....
I'm building a timesheet and right now the pay period is setup to manually enter it...using start dates and end dates, and user just selects the pay period from a dropdown list. What I would like to achieve is to have the pay period automatic (no initial setup).
I'm not clear on how to start as we have semi monthly pay, Starting on 1st of Month and the 16th to the end of the month.
I do have a variable created in a calendar that gets the first of the month called varFirstDayofMonth ( = 1).
I'm assuming a forall and sequence but not clear how to put it together with the two starting pay period dates each month. Any ideas or direction would be great. Thanks for your help.
Solved! Go to Solution.
Hi @TB05
Set the Default property of Dropdown to
With(
{
CurrentDate: Day(Now()),
StartMonth: DateValue(Month(Now()) & "/1/" & Year(Now())),
FirstHalfEndMonth: DateValue(Month(Now()) & "/15/" & Year(Now())),
SecondHalfStartMonth: DateValue(Month(Now()) & "/16/" & Year(Now())),
MonthEnd: DateAdd(
DateValue(Month(Now()) + 1 & "/1/" & Year(Now())),
-1,
Days
)
},
If(
CurrentDate < 16,
StartMonth & " - " & FirstHalfEndMonth,
SecondHalfStartMonth & " - " & MonthEnd
)
)
We need to create 2 another variables to store StartDate and End Date. Set OnVisible property of screen to
Set(
varPayPeriodSelectedDropdownStartDate,
With(
{
CurrentDate: Day(Now()),
StartMonth: DateValue(Month(Now()) & "/1/" & Year(Now())),
SecondHalfStartMonth: DateValue(Month(Now()) & "/16/" & Year(Now()))
},
If(
CurrentDate < 16,
StartMonth,
SecondHalfStartMonth
)
)
);
Set(
varPayPeriodSelectedDropdownEndDate,
With(
{
CurrentDate: Day(Now()),
FirstHalfEndMonth: DateValue(Month(Now()) & "/15/" & Year(Now())),
MonthEnd: DateAdd(
DateValue(Month(Now()) + 1 & "/1/" & Year(Now())),
-1,
Days
)
},
If(
CurrentDate < 16,
FirstHalfEndMonth,
MonthEnd
)
)
);
And also OnChange property of payperiod dropdown to
Set(varPayPeriodSelectedDropdownStartDate, PayPeriodDropdown.Selected.StartDate);
Set(varPayPeriodSelectedDropdownEndDate, PayPeriodDropdown.Selected.EndDate);
Hi @TB05
I assume you have a dropdown to pick up the pay period like
Set the DefaultDate for the StartDate to
If(Value(PayPeriod.Selected.Value)=1, DateValue(Month(Now()) & "/1/" & Year(Now())),DateValue(Month(Now()) & "/16/" & Year(Now())))
Set the DefaultDate of EndDate to
If(
Value(PayPeriod.Selected.Value) = 1,
DateValue(Month(Now()) & "/15/" & Year(Now())),
DateAdd(
DateValue(Month(Now()) + 1 & "/1/" & Year(Now())),
-1,
Days
)
)
Please let me know if anything is misunderstood.
Thanks,
Stalin - Learn To Illuminate
Hi, thank you for responding.
Yes, so currently I have a dropdown list that is populated with pay period selection.
I want the dropdown pay period to default to the pay period within the current date.
The dropdown title is a combination of a StartDate & EndDate.
Hi @TB05
Set the Default property of Dropdown to
With(
{
CurrentDate: Day(Now()),
StartMonth: DateValue(Month(Now()) & "/1/" & Year(Now())),
FirstHalfEndMonth: DateValue(Month(Now()) & "/15/" & Year(Now())),
SecondHalfStartMonth: DateValue(Month(Now()) & "/16/" & Year(Now())),
MonthEnd: DateAdd(
DateValue(Month(Now()) + 1 & "/1/" & Year(Now())),
-1,
Days
)
},
If(
CurrentDate < 16,
StartMonth & " - " & FirstHalfEndMonth,
SecondHalfStartMonth & " - " & MonthEnd
)
)
That worked great!
@StalinPonnusamy The solution works great for what I want but now, where the user is not selecting the payperiod as it is defaulted, how do I set the variable for the pay period? As I'm using a variable through my app. If user selects an item in the list, onchange I have the following:
Set(varPayPeriodSelectedDropdown, Dropdown7.Selected); this is working but not set when user doesn't select. I thought I could add this code to the app on visible screen and it would set the variable. How do I set the variable to the defaulted pay period if user does not select it?
Hi @TB05
We can move the formula to OnVisible property of the screen then.
Set Onvisible property of the screen to
Set(
varPayPeriodSelectedDropdown,
With(
{
CurrentDate: Day(Now()),
StartMonth: DateValue(Month(Now()) & "/1/" & Year(Now())),
FirstHalfEndMonth: DateValue(Month(Now()) & "/15/" & Year(Now())),
SecondHalfStartMonth: DateValue(Month(Now()) & "/16/" & Year(Now())),
MonthEnd: DateAdd(
DateValue(Month(Now()) + 1 & "/1/" & Year(Now())),
-1,
Days
)
},
If(
CurrentDate < 16,
StartMonth & " - " & FirstHalfEndMonth,
SecondHalfStartMonth & " - " & MonthEnd
)
)
);
Set Default Property of PayPeriod Dropdown to
varPayPeriodSelectedDropdown
Thanks,
Stalin - Learn To Illuminate
I made that change and am seeing the variable output to be the current Pay Period.
Throughout this application, I was using the varPayPeriodSelectedDropdown.StartDate and *.EndDate, I have a lot of conditions and error checking based around that variable. Using the solution provided I'm unable to achieve this. I'm not making reference to the rest of the list (thisitem). Any thoughts on how we can achieve that?
We need to create 2 another variables to store StartDate and End Date. Set OnVisible property of screen to
Set(
varPayPeriodSelectedDropdownStartDate,
With(
{
CurrentDate: Day(Now()),
StartMonth: DateValue(Month(Now()) & "/1/" & Year(Now())),
SecondHalfStartMonth: DateValue(Month(Now()) & "/16/" & Year(Now()))
},
If(
CurrentDate < 16,
StartMonth,
SecondHalfStartMonth
)
)
);
Set(
varPayPeriodSelectedDropdownEndDate,
With(
{
CurrentDate: Day(Now()),
FirstHalfEndMonth: DateValue(Month(Now()) & "/15/" & Year(Now())),
MonthEnd: DateAdd(
DateValue(Month(Now()) + 1 & "/1/" & Year(Now())),
-1,
Days
)
},
If(
CurrentDate < 16,
FirstHalfEndMonth,
MonthEnd
)
)
);
And also OnChange property of payperiod dropdown to
Set(varPayPeriodSelectedDropdownStartDate, PayPeriodDropdown.Selected.StartDate);
Set(varPayPeriodSelectedDropdownEndDate, PayPeriodDropdown.Selected.EndDate);
Thank you so much! You have been unbelievably helpful.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
187 | |
70 | |
49 | |
36 | |
25 |
User | Count |
---|---|
239 | |
111 | |
89 | |
88 | |
66 |