Ethan
Ethan

Reputation: 2784

Setting a Trend Chart to "Last 30 Days" in Qlikview 11

I am trying to create a column graph that regardless of whichever date filters are selected, it will always show only the past 30 days worth of data. I have the date values in Excel format as the field [Raw Excel Date]. No idea how to do this, as I am relatively new to Qlikview development. Any help is greatly appreciated.

Some additional info- The expression I am using right now that is displaying the trend across all dates is simply COUNT([ThingID]).

Upvotes: 0

Views: 3828

Answers (1)

Stefan Stoychev
Stefan Stoychev

Reputation: 5012

Lets assume that the data look like this:

(not sure in what format is the date that you have. I assume that the format is YYYY-MM-DD)

Raw Excel Date, ThingID
2014-01-01    , 10
2014-01-02    , 20
2014-01-03    , 30
2014-01-04    , 40
2014-01-05    , 50

Then you need to create one variable (vMaxDate in my case):

= date(max({1} [Raw Excel Date] ), 'YYYY-MM-DD')

The above variable will always return the max possible data in your data set no matter the selections (not only the data selection but any selection)

Then in your chart you can use expressions like this:

count({< [Raw Excel Date]=,  [Raw Excel Date] = {"<=$(=( date(vMaxDate)))>=$(=( date(vMaxDate - 30)))"}>} [ThingID])

The set analysis in the expression will ignore all selections in [Raw Excel Date] field and then will "select" (internally) only the values in [Raw Excel Date] which are less than (and equal) to the value in vMaxDate and bigger than (and equal) vMaxDate-30 values.

Stefan

Upvotes: 1

Related Questions