Hi All,
I Have issue with my Leave App, My startdate and End date are both holidays, but my number of days still counting as 1 day. My number of days should be Zero.
Please see below
Can you help me with this. Thank you.
Code :
If(varCalculationActive1,
If(
Leavetype.Selected.Value = "Maternity leave",
If(
StartDates.SelectedDate <= EndDates.SelectedDate,
DateDiff(
StartDates.SelectedDate,
EndDates.SelectedDate,
Days
) + 1 - If(
Checkbox3.Value,
0.5
)
),
(If(
StartDates.SelectedDate = EndDates.SelectedDate,
Sum(
If(
Weekday(StartDates.SelectedDate) = 1,
0,
1
)
) - If(
Checkbox3.Value,
0.5
),
If(
StartDates.SelectedDate > EndDates.SelectedDate,
-Sum(
ForAll(
Sequence(
DateDiff(
EndDates.SelectedDate,
StartDates.SelectedDate,
Days
),
0,
1
),
If(
Weekday(
DateAdd(
EndDates.SelectedDate,
Value
)
) = 1,
{DayCount: 0},
{DayCount: 1}
)
),
DayCount
) - If(
Checkbox3.Value = false,
0.5
) - 1/2,
Sum(
ForAll(
Sequence(
DateDiff(
StartDates.SelectedDate,
EndDates.SelectedDate,
Days
),
0,
1
),
If(
Weekday(
DateAdd(
StartDates.SelectedDate,
Value
)
) = 1,
{DayCount: 0},
{DayCount: 1}
)
),
DayCount
) + If(
Checkbox3.Value = false,
0.5
) + 1 / 2
) - CountRows(
Filter(
colHolidays,
HolidayDates >= StartDates.SelectedDate,
HolidayDates <= EndDates.SelectedDate
)
)
))
)
)
In PowerApps, you typically don’t nest If()’s. You use If() like this
If( Condition1, ThenResult1 [, Condition2, ThenResult2, ... [ , DefaultResult ] ] )
So just 1 If statement. Try re-writing you logic using this structure and you may find you get what you need? As a tip, I tend to comment my large If statements so that I don’t get lost in the logic … which can easily happen!
Hi @pword ,
With this kind of situation, you could add a few Labels, copy and paste each parts of the formula and check the results. It's difficult for us to reproduce the issue and find the source.
Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
182 | |
47 | |
46 | |
34 | |
33 |
User | Count |
---|---|
260 | |
87 | |
79 | |
68 | |
67 |