Hello!
Iโve been trying to play around with an expression for a slice that will allow me to show all the employees that have not had a visitation record created for them in the last 4 weeks.
Iโve come up with things like the following:
IF(TODAY() > (MAXROW(โTrainee Recordsโ, โDateโ)+28),TRUE, FALSE)
MAXROW(โTrainee Recordsโ, โDateโ, (IF(TODAY() > ([DATE] + 28)),YES,NO))
None of them have really worked
The main part of my data is the one worksheet (EmployeeRecords) where I have all the visitation records recorded with headings such as ,[Date], [Site], [Employee Name], [Work Overview]. I would have multiple records for the same employee at different dates (i.e. as such RowNumber has become my key).
I would like to be able to have a slice (and then subsequent format rules to make it pretty) that looks at the latest date/visit per Employee in the EmployeeRecords table, then see if that date is more than X days ago (e.g. 4 weeks). If the latest date is more than 4 weeks ago, I want it in the slice. I do not want the slice to show records where the date is more than 4 weeks ago BUT it is not the latest date for any given employee.
I appreciate any advise.
Solved! Go to Solution.
Nice work. That looks correct to me.
Sure, I can try.
So you have 2 conditions that each record in your Table must match to be in your slice. Those are your 2 arguments in the AND().
Iโm sure you understand the [Date] comparison.
So for the other argument, youโre wanting to match if the record is the latest record for the same Trainee as in the current record (the condition is evaluated iteratively across all records, so the โcurrentโ record changes every time). For every record of the same Trainee, the MAXROW() expression is going to return the same key value, but you only want it to match a single record. So with just this single condition, youโre getting only the latest record per each Trainee.
Another expression you could have used for this condition, which may make more sense to you, is this:
[Date] =
MAX( SELECT(
Trainee Record[Date] ,
[Trainee Name] = [_THISROW].[Trainee Name]
) )
IF( condition , TRUE , FALSE)
is redundant. Just use condition
.*
hint*
hint*
), that the date is > X.Try it out again with these in mind. If you still canโt figure it out I can provide more help.
Additional note:
_RowNumber as a Key is very much not recommended.
Hi Marc
Thanks for your response.
I tried messing around with this:
AND(MAXROW(โTrainee Recordsโ, โDateโ, ([Date] < [_THISROW].[Date])),TODAY() > ([DATE] + 28))
I get this:
Condition AND(ANY(SELECT(Trainee Records[_RowNumber],AND(([Date] < [_THISROW].[Date]), ([Date] = MAX(SELECT(Trainee Records[Date],([Date] < [_THISROW].[Date]))))))), (TODAY() > ([DATE]+28))) has an invalid structure: subexpressions must be Yes/No conditions
As far as I can tell TODAY() > ([DATE] + 28) works in the slice but it will also pull ALL dates and not the most recent (if past X days).
Iโm not sure how to combine the different expressions to only get the latest record for each employee if its past x days.
Also quickly in regards to the key, I could always create a UNIQUEID() column and hide it - but I am currently the only app user, so Iโm not too worried about using RowNumber as the key for now.
Any further advise appreciated
Again, MAXROW() returns a key value, not a Yes/No value. You need to compare it against something.
Your third argument in MAXROW isnโt helping you. Since youโre wanting the latest date per employee, the third argument should handle that requirement.
Hi Marc
This is what Iโve come up with after looking deeper at other use cases such as this one: Select the last/latest date in a table (rows)
AND(([_THISROW]=MAXROW(โTrainee Recordsโ,โDateโ,([_THISROW].[Trainee Name]=[Trainee Name]))),TODAY() > ([DATE] + 28))
I think it is working but not sure I completely understand the format. At this point Iโm throwing things in a pot and seeing what happens
Would you be able to help me break it down?
Thanks again.
Nice work. That looks correct to me.
Sure, I can try.
So you have 2 conditions that each record in your Table must match to be in your slice. Those are your 2 arguments in the AND().
Iโm sure you understand the [Date] comparison.
So for the other argument, youโre wanting to match if the record is the latest record for the same Trainee as in the current record (the condition is evaluated iteratively across all records, so the โcurrentโ record changes every time). For every record of the same Trainee, the MAXROW() expression is going to return the same key value, but you only want it to match a single record. So with just this single condition, youโre getting only the latest record per each Trainee.
Another expression you could have used for this condition, which may make more sense to you, is this:
[Date] =
MAX( SELECT(
Trainee Record[Date] ,
[Trainee Name] = [_THISROW].[Trainee Name]
) )
Hi Marc
Yes that way does seem much more easier to follow than the one I pasted above.
So essentially the full thing would look like
AND(([Date] = MAX( SELECT(Trainee Record[Date] ,[Trainee Name] = [_THISROW].[Trainee Name]) ), TODAY() > ([DATE] + 28))
Apologies for not getting back to this sooner, I have about four different posts going for the one application - trying to take it all onboard.
Thank you again for your continued assistance!
User | Count |
---|---|
16 | |
9 | |
9 | |
7 | |
3 |