Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
joey_lutes
Partner - Creator
Partner - Creator

Dynamic Date Range Line Chart

I have 2 tables.  One event table, one data table.

This is all time-series data.  From the Data table, an event is recognized, and established in the Event Table (outside of Qlik).

So - for example,

Data is perpetual, timestamped every minute:  Let's say that happens for a month (jan 1 - jan31)

An event occurs on Jan 10, lasting 16 hours into Jan 11.

Event:

id, startTimeStamp, endTimeStamp, eventdata1

Data:

id, dataTimeStamp, data2, data3, data4

I have formatted all the dates/times and created a DateLink table for a commonDate, loading the 3 dates independently and assigning dateTypes.  (Search Recipes | Qlikview Cookbook)

What I'd like to see is:

DURING the event window (in this case 1/10-1/11) what was the associated data from the Data Table.

So, in a line chart, I'd like my date range to be dynamic by selection of id.  In the date dimension, my latest attempt is:

if(dataTimeStamp <= min(startTimeStamp) AND dataTimeStamp >= max(endTimeStamp), dataTimeStamp)

Sense hates this and produces invalid dimension.  I have verified syntax and all seems to be good.  I've tried removing min and max functions as well, still not producing a valid result.

Thoughts?

4 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

It is because aggregation without advanced aggregation function is not allowed in dimension.

What you should do is

1. Create 2 variables. 1 to store the Start and other to store the End. Like below

vMin = min(startTimeStamp)

vMax = max(endTimeStamp)


Now replace the Max and Min function in your dimension expression with this variables.

if(dataTimeStamp <=$(vMin) AND dataTimeStamp >= $(vMax), dataTimeStamp)


Hope this helps.


Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
pradosh_thakur
Master II
Master II

what if you put =min(startTimeStamp) and =max(endTimeStamp) in two variables and use it in the expression. don't forget to put = in the variable definition.

Lets see if sense still hates it ..

Learning never stops.
joey_lutes
Partner - Creator
Partner - Creator
Author

I actually thought about that but didn't try it.

I did it, and it's still giving me fits, though it's a little better.

While the graph does display correctly with no selections, when an id is selected, it breaks (though no invalid dimension error). 

After further review, the variable is not calculating correctly:

I added a couple KPIs to the page to view,

min(startTimeStamp) shows the accurate date while $(vMinStart) shows something completely different (1905 date).

Weird because I added the variable correctly it would seem.

=min(startTimeStamp)

when I do the same thing in the KPI, it produces a different result.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Seems there is something wrong with the data type of the dates.

Can you share sample data.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!