Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
vgadang1
Partner - Contributor III
Partner - Contributor III

If (interval)

Hi,

I am new to Qlik sense, I am working with a measure 

if(interval(today(2)-daystart(max({<[Session Count] = {1}>} LogTimeStamp)),'d')>45, null())

The expected result is if days more than 45 then return number of days since last accessed app, else null. The problem is this returns all nulls even when the number of days are more than 45, see screenshot below. 

vgadang1_0-1667500621498.png

 

7 Replies
BrunPierre
Partner - Master
Partner - Master

Try with Now(2) instead of Today(2) since you're working with a timestamp.

vgadang1
Partner - Contributor III
Partner - Contributor III
Author

Hi @BrunPierre , 

I tried it, still get the same result. I also tried few things, I created a measure to calculate the number of days since last accessed (master measure and named it "Last accessed session"

interval(today(2)-daystart(max({<[Session Count] = {1}>} LogTimeStamp)),'d')

Then created another measure =if([Last accessed session] >= 45, 1, 0), I get all 0 

The problem is the with the Days since last accessed? it is formatted as integer so not sure why it returns all zeros 

MarcoWedel

please post some sample data for all relevant fields and your expected result.

BrunPierre
Partner - Master
Partner - Master

if(interval(Today(2)-TimeStamp(max({<[Session Count] = {1}>} LogTimeStamp)),'d')>45, null())

or as @MarcoWedel suggested.

Sarchiz
Partner - Contributor II
Partner - Contributor II

Maybe not working because of the "45" ? Comparing dates with numbers doesn't always go well...

marcus_sommer

There is no else-branch specified which means returning NULL for it and therefore you query returned it: if(condition, null(), null())

- Marcus

vgadang1
Partner - Contributor III
Partner - Contributor III
Author

@marcus_sommer To your point I tried this another way I described it in this thread, but reiterating it here,

I created a measure to calculate the number of days since last accessed (master measure and named it "Last accessed session" - interval(today(2)-daystart(max({<[Session Count] = {1}>} LogTimeStamp)),'d')

Then created another measure =if([Last accessed session] >= 45, 1, 0), I get all 0 

The problem is with the Days since last accessed? it is formatted as integer so not sure why it returns all zeros so I tried to format it to Num() and also tried Ceil() I still get all zeros