I wanted the app to not allow to save if the last 3 values in column [shift] are not yet 3 of the same [shift]. my expression is still allowing the save. can please hep me figure it out.
For example: if the last 3 values are “AM”, then allow it to be “PM” for the next value, and “GY” is the allowable next value if the last 3 values in [shift] column are “GY”.
here is my Valid if expression:
IFS([Most Recent].[Shift]=“AM”,Count(Select(Timesheet[SHIFT],And([Shift]=“AM”,[Date]=[_thisrow].[Date])))<=3,
[Most Recent].[Shift]=“PM”,Count(Select(Timesheet[SHIFT],And([Shift]=“PM”,[Date]=[_thisrow].[Date])))<=3,
[Most Recent].[Shift]=“GY”,Count(Select(Timesheet[SHIFT],And([Shift]=“GY”,[Date]=[_thisrow].[Date])))<=3)
This is confusing. Is there a mistake? Allow PM if the last 3 are AM but then allow GY if the last three are also GY?
And what defines “the last 3”? Last 3 timesheet entries? Last 3 timesheet entries for this user? Your sample expression is checking for ANY 3 or less with the same Date.
Please explain what your goal is, what you are trying to have the app do. We may be able to help better
2 Likes
yes, too confusing for me too.
I wanted to automatically change the shift if the last 3 values are already the same. Meaning, if they are 3 AM already then the new row should be PM. if the last 3 values are PM then the new value should be GY.
so I have revised and added the “AND” and “OR” conditions into my expression:
first, I have created 1 VC for each Shift (AM Count, PM COunt, and GY Count). then this expression:
IFS(
OR(and([Most Recent].[Shift]=“AM”,[AM Count]<3),[GY Count]=3),“AM”,
OR(and([Most Recent].[Shift]=“PM”,[PM Count]<3),[AM Count]=3),“PM”,
OR(and([Most Recent].[Shift]=“GY”,[GY Count]<3),[PM Count]=3),“GY”
)
so far works well, I am still testing it.
Yes this makes much more sense to me now. I think you could simplify if you were to reverse the logic to match your explanation:
IFS(
and([Most Recent].[Shift]="AM",[AM Count]=3), "PM",
and([Most Recent].[Shift]="PM",[PM Count]=3), "GY",
and([Most Recent].[Shift]="GY",[GY Count]=3), "AM"
)
1 Like