Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Qlik Sense count rows within last week

Hi all,

I am trying to make a KPI to count the number of errors occurring in the last week (InputType = Error). I thought this would be simple but I am having far more trouble than I should with it. I have been trying to use variations of =Count({<InputType = {'Error'}, Date = {'>=(Today()-7)'} >} InputType).


I have a feeling it not working may be due to different date formats, but I cannot get anything to work, even when trying to use date() and similar to convert the dates. It only seems to be summing Errors from all time and ignoring the date range.


DateVersionSiteErrorInputType
2017-12-092.5AAAThings brokeError
2017-12-092.3SSS0.74Stat
2017-12-072.3BBB0.65Stat
2017-11-312.1AAASomething went wrongError


Any help would be much appreciated.

Thanks


1 Solution

Accepted Solutions
sunny_talwar

Try this out

=Count({<InputType = {'Error'}, Date = {">=$(=Date(Today()-7, 'YYYY-MM-DD'))"}>} InputType).

View solution in original post

7 Replies
sunny_talwar

Try this out

=Count({<InputType = {'Error'}, Date = {">=$(=Date(Today()-7, 'YYYY-MM-DD'))"}>} InputType).

jonvitale
Creator III
Creator III

Chris,

I suggest working this out step-by-step. You have a nice little table there. Try adding a measure to it: IF(Date > Today() - 7, 1, 0). Work out from there.

You may also want consider creating an extra field called DateNum, which would be Num(Date). This might make it easier to do comparisons.

Finally, in your load script, make sure that your DateFormat is 'YYYY-MM-DD'. It's not the default.

Anonymous
Not applicable
Author

Ohhh that's how you convert the date.

Thank you very much, works perfrectly

jonvitale
Creator III
Creator III

Sunny, how's anyone suppose to get points around here with you answering all the questions?

Anonymous
Not applicable
Author

Thank you for that, I think that would be a good practice to start and a good method to try things

YoussefBelloum
Champion
Champion

Hi,

you can try this:


=Count({<InputType = {'Error'}, Date ={"$(= '>=' &date(today()-7))"} >} InputType)

sunny_talwar

I am done for the day