Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

joeybird
Contributor II

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
Contributor II

Re: show last 24 hours only - Qlik sense

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

19 Replies

Re: show last 24 hours only - Qlik sense

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
Contributor II

Re: show last 24 hours only - Qlik sense

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

Re: show last 24 hours only - Qlik sense

May be like this

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

joeybird
Contributor II

Re: show last 24 hours only - Qlik sense

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

Re: show last 24 hours only - Qlik sense

Not sure I understand what you mean?

joeybird
Contributor II

Re: show last 24 hours only - Qlik sense

hi

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

please help 

Re: show last 24 hours only - Qlik sense

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

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

joeybird
Contributor II

Re: show last 24 hours only - Qlik sense

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

Re: show last 24 hours only - Qlik sense

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?

Community Browser