With Question
Remember that comment in the live stream about needing to work on WITH? Here is an example... I am working on this app for our operator's work schedule. I got the schedule figured out and it populates correctly. What I am working on now is the Time Off portion. I was able to use 's trick to use With to generate a one-column table of all dates between start date & end date for the request. It worked great when I was just looking at vacation, but we have 11 different "codes" for types of time off, vacation being one. So I tried to add another clause to the with to select the type of time the operator was taking off. In the images I have shown the month of February. I have also shown the "requests" that I have in the Dataverse table in the second image. The problem is that the holiday shows for 2/17, but the NA I have for 2/28 does not appear. It is as though the With doesn't look at the second clause for each row in the collection. Here is the code for the label in the date under my name on 2/17:
With(
{
// generate a one-column table of all dates between start date & end date
varDateRange: ForAll(
Sequence(
LookUp(
colTimeOffThisMonth,
'Last Name' = lblLeadOperatorName.Text,
'End Date'
) - LookUp(
colTimeOffThisMonth,
'Last Name' = lblLeadOperatorName.Text,
'Start Date'
) + 1
),
LookUp(
colTimeOffThisMonth,
'Last Name' = lblLeadOperatorName.Text,
'Start Date'
) + Value - 1
), varTimeOffType:LookUp(colTimeOffThisMonth,Type=ThisRecord.Type,Type)
},
If(
CountIf(
varDateRange,
Month(Value) = Month(_firstDayOfMonth),
Day(Value) = 17
) = 0,
"",
If(
CountIf(
varDateRange,
Month(Value) = Month(_firstDayOfMonth),
Day(Value) = 17
) = 1,
If(
lblLeadOperator17.Text = "X",
"NA",
Switch(
varTimeOffType,
1,
LookUp(fxTimeOffTypes,cre9a_id=1,cre9a_timeoffcode),
2,
LookUp(fxTimeOffTypes,cre9a_id=2,cre9a_timeoffcode),
3,
LookUp(fxTimeOffTypes,cre9a_id=3,cre9a_timeoffcode),
4,
LookUp(fxTimeOffTypes,cre9a_id=4,cre9a_timeoffcode),
5,
LookUp(fxTimeOffTypes,cre9a_id=5,cre9a_timeoffcode),
6,
LookUp(fxTimeOffTypes,cre9a_id=6,cre9a_timeoffcode),
7,
LookUp(fxTimeOffTypes,cre9a_id=7,cre9a_timeoffcode),
8,
LookUp(fxTimeOffTypes,cre9a_id=8,cre9a_timeoffcode),
9,
LookUp(fxTimeOffTypes,cre9a_id=9,cre9a_timeoffcode),
10,
LookUp(fxTimeOffTypes,cre9a_id=10,cre9a_timeoffcode),
11,
LookUp(fxTimeOffTypes,cre9a_id=11,cre9a_timeoffcode)
)
)
)
)
)
Any ideas why the same code ( with 28 substituted for the 17's in the Day(Value) checks and the label name) won't populate the correct value?
2
2 comments
Dustin Rocksvold
5
With Question
Learn Power Apps
skool.com/learn-power-apps
A community of people who are enthusiastic about and trying to learn about Microsoft's Power Apps!
Powered by