Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
joeybird
Creator III
Creator III

show last 24 hours only - Qlik sense


Hi

looking to find how I can use set analysis to only show the last 24 hours of activity

dimension is OrderDateHour

example

01/01/2001 01:00:00

01/01/2001 02:00:00

01/01/2001 03:00:00

I have to this split into separate fields as OrderDate and OrderHour

I have found code that takes away the last 24 hours, but that's not what I am  looking to do

any ideas please

Kind Regards

1 Solution

Accepted Solutions
joeybird
Creator III
Creator III
Author

Hi

think we have it team

the answer is

DateTimeField = {"$(='>' & TimeStamp(Min(DateTimeField), 'DD/MM/YYYY hh:mm:ss') & '<=' & TimeStamp(Max(DateTimeField), 'DD/MM/YYYY hh:mm:ss'))"}

thanks team your awesome , bit of each Sunny and Pradosh code got it working

Kind Regards

View solution in original post

19 Replies
sunny_talwar

May be create a flag in the script for last 24 hours? But last 24 hours from what? the max date and time or now()? But this now can vary

joeybird
Creator III
Creator III
Author

HI

It would be from the max date and hour

so at moment max date and hour is  19/09/2017 13:00

so from 13:00 going backwards each hour for the last 24 hours only (this would be sorted then on the chart)

Please help

sunny_talwar

May be like this

{<DateTimeField = {"$(='>=' & TimeStamp(Max(DateTimeField) - 1, 'DD/MM/YYYY hh:mm') & '<=' & TimeStamp(Max(DateTimeField), 'DD/MM/YYYY hh:mm'))"}>}

joeybird
Creator III
Creator III
Author

Hi

this seems to work, thanks Sunny , but on the latest hour so e.g. 13:00 today  it seems to double the figure ...

its adding todays 19/09/2017 13:00 with yesterdays  18 /09/2017 13:00 figure

please help

sunny_talwar

Not sure I understand what you mean?

joeybird
Creator III
Creator III
Author

hi

the max hour today's 13:00:00 is being added to yesterday's 13:00 hour's figure

please help 

sunny_talwar

so if max is 13, then you want to get this range, right

>=18/09/2017 13:00<=19/09/2017 13:00?

joeybird
Creator III
Creator III
Author

Hi

yes sort off

the calculation you made is sort of working, but its adding todays and yesterdays 13:00 time values (only the max hour is added double)

{<DateTimeField = {"$(='>=' & TimeStamp(Max(DateTimeField) - 1, 'DD/MM/YYYY hh:mm') & '<=' & TimeStamp(Max(DateTimeField), 'DD/MM/YYYY hh:mm'))"}>}


If I take away the -1 from the code

{<DateTimeField = {"$(='>=' & TimeStamp(Max(DateTimeField), 'DD/MM/YYYY hh:mm') & '<=' & TimeStamp(Max(DateTimeField), 'DD/MM/YYYY hh:mm'))"}>}

I get the correct number for todays 13:00 hour figure but all 0 for the other hours

Please help

sunny_talwar

yes sort off

What is sort off mean... if you don't need this

>=18/09/2017 13:00<=19/09/2017 13:00

then what exactly do you need?