4 Replies Latest reply: Jan 25, 2018 2:48 PM by Kaushik Solanki RSS

    Dynamic Date Range Line Chart

    Joey Lutes

      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?

        • Re: Dynamic Date Range Line Chart
          Kaushik Solanki

          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

           

            • Re: Dynamic Date Range Line Chart
              Joey Lutes

              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
              pradosh thakur

              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 ..