Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a set of data below showing entries by staff from 2 Oct to 15 Oct and I need to use Qlik to show 2 things:
1. How many staff did not provide entries for 2 days or more (Ans: 2).
2. Show who are the staff who did not provide entries for 2 days or more (Ans: Staff 10 and Staff 1002).
Can anybody please advise? Thank you in advance.
Staff Name | Temperature | Recorded On |
Staff 1 | 36.8 | 02/10/2020 |
Staff 1 | 36.9 | 03/10/2020 |
Staff 1 | 36.9 | 04/10/2020 |
Staff 1 | 36.8 | 05/10/2020 |
Staff 1 | 36.8 | 06/10/2020 |
Staff 1 | 36.8 | 07/10/2020 |
Staff 1 | 36.8 | 08/10/2020 |
Staff 1 | 36.7 | 09/10/2020 |
Staff 1 | 36.8 | 10/10/2020 |
Staff 1 | 36.9 | 11/10/2020 |
Staff 1 | 36.9 | 12/10/2020 |
Staff 1 | 36.8 | 13/10/2020 |
Staff 1 | 36.8 | 14/10/2020 |
Staff 1 | 36.8 | 15/10/2020 |
Staff 10 | 36 | 02/10/2020 |
Staff 10 | 36 | 06/10/2020 |
Staff 10 | 36 | 07/10/2020 |
Staff 10 | 36 | 08/10/2020 |
Staff 10 | 36 | 09/10/2020 |
Staff 10 | 36 | 10/10/2020 |
Staff 10 | 36 | 12/10/2020 |
Staff 10 | 36 | 13/10/2020 |
Staff 10 | 36 | 14/10/2020 |
Staff 1002 | 36.5 | 02/10/2020 |
Staff 1002 | 36.5 | 03/10/2020 |
Staff 1002 | 36.5 | 04/10/2020 |
Staff 1002 | 36.5 | 06/10/2020 |
Staff 1002 | 36.5 | 07/10/2020 |
Staff 1002 | 36.5 | 09/10/2020 |
Staff 1002 | 36.5 | 10/10/2020 |
Hi @Jarvay , for the fist one you can use:
=Sum(Aggr(If(Count(DISTINCT [Recorded On])<Count(DISTINCT TOTAL [Recorded On]),1), [Staff Name]))
and for the 2nd:
=Concat(Aggr(If(Count(DISTINCT [Recorded On])<Count(DISTINCT TOTAL [Recorded On]),[Staff Name]), [Staff Name]), ',')
Hi Rubenmarin,
Thanks for the advice! Sorry but I forgot to to add that the staff has to have missed providing inputs for consecutively 2 days before it is considered as a count. My bad...
Hi @Jarvay then it will be better to flag those records on script... and if the staff misses for 4 consecutive days it counts as 1, or 2 or 3?
// Cartesian of staff and dates
tmpStaffDates:
LOAD
FieldValue('Staff Name', RecNo()) as [Staff Name]
AutoGenerate FieldValueCount('Staff Name');
Outer Join (tmpStaffDates)
LOAD
FieldValue('Recorded On', RecNo()) as [Recorded On]
AutoGenerate FieldValueCount('Recorded On');
// Add values (the ones witout values will be null)
Left Join (tmpStaffDates)
LOAD [Staff Name], [Recorded On], Temperature
Resident TableDataName;
// Remove previous data table to keep the temporary as the data table
DROP Table TableDataName;
// Flag records
TableDataName:
LOAD [Staff Name], [Recorded On], Temperature,
If(Peek([Staff Name])=[Staff Name] and IsNull(Temperature) and IsNull(Peek(Temperature))
,If(Peek(isGap)=0 and not IsNull(Peek(Temperature,-2)), 1, 0) //This is to flag only the first 2 days gap
,0) as isGap
Resident tmpStaffDates
Order By [Staff Name], [Recorded On];
// Remove temporary table
DROP Table tmpStaffDates;
Expression can be:
- Sum(isGap)
- Concat(DISTINCT {<isGap={1}>} [Staff Name], ', ')
Hi Rubenmarin,
A big thanks! Looks complicated for a beginner like me but will take some time to study the solution.
And if the staff misses providing inputs for 4 consecutive days, it should count as 1.