Qlik Community

Qlik Sense App Development

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

joey_lutes
Contributor

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

Re: Dynamic Date Range Line Chart

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

pradosh_thakur
Honored Contributor II

Re: Dynamic Date Range Line Chart

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
Contributor

Re: Dynamic Date Range Line Chart

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.

Re: Dynamic Date Range Line Chart

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

Can you share sample data.

Regards,

Kaushik Solanki

Community Browser