Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

stevegimbrollmt
Contributor II

date range in X Axis Dimension by selected one date

I have a line chart and I want that when i select lets say 15-04-2011, in the line chart, I actually get a range from 15-03-2011 to 15-04-2011 rather than showing just one date selected.

I have tried doing something with the calculated dimension but seems its not workign and also the Min/Max Scale expression only work for the Y Axis.

Is this possible?

Thanks!

Steve

1 Solution

Accepted Solutions
MVP
MVP

Re: date range in X Axis Dimension by selected one date

Ah, yes, you need to use set analysis to ignore every other date-related field associated with created_date.  This is normally done by listing them explicitly:

if(GetSelectedCount(Day)> 1,Sum(actual_turnover),Sum({<[created_date]={">=$(=date(min(created_date)-30))<=$(=date(max(created_date)))"},Day=,Month=,Year=>} actual_turnover))

There's also a way to tell QlikView "ignore every field in the calendar table except for created_date", but you'd probably reserve that for if there are a lot of fields in the table to be ignored.

11 Replies
Not applicable

date range in X Axis Dimension by selected one date

You would probably be better off using variables than actual selections.  Set up one variable called like vMinDate and one called vMaxDate.  Make an input box for vMaxDate, and in the variable overview set vMinDate to: =date(vMaxDate-1)

Then in the line chart expression, use set analysis like this:

[code]

{$<[Date]={">=$(vMinDate) <=$(vMaxDate)"}>}

[/code]

Or you could not set vMinDate to anything and have an input box for both vMinDate and vMaxDate.

MVP
MVP

Re: date range in X Axis Dimension by selected one date

I'd probably just stick with fields instead of variables.  It's very much the same basic idea, though - use set analysis to pretend you selected more dates than you actually selected.  Something like this, maybe:

{<[Date]={">=$(=date(min(Date)-1) <=$(=date(max(Date))))"}>}

stevegimbrollmt
Contributor II

date range in X Axis Dimension by selected one date

thanks for your feedback guys, im gona try it now, sorry for late reply but got stuck on something else, but from

Trent feedback: I understand what you mean but not sure if its exactly what  I want but will try it out.

John: thanks as always, to be honest I tried something like that, not sure if the modifier was wrong but will try your sample.

stevegimbrollmt
Contributor II

date range in X Axis Dimension by selected one date

hmmm John not sure if I did this correct but in the chart expression I have put this expression

if(GetSelectedCount(Day)> 1,Sum(actual_turnover),Sum({<[created_date]={'>=$(=date(min(created_date)-30))<=$(=date(max(created_date)))'}>} actual_turnover))

My aim is that if I select just 1 day, I want to see a date range of 30 days, if not, it just shows the selected days.

Is this possible?

Thanks guys!!

MVP
MVP

date range in X Axis Dimension by selected one date

Double quotes, not single quotes.  Other than that it looks right to me, but I could be missing something.

stevegimbrollmt
Contributor II

date range in X Axis Dimension by selected one date

Thanks for your help. It still not working as in, it still shows me selected day only rather than a range of 30 days on the axis.

I need to find a way how when I select  30-03-2011, on the graph i see displayed dates 01-03-2011,02-03-2011...etc etc till 30-03-2011.


Will need to find a way to do it.  Thanks again John

stevegimbrollmt
Contributor II

date range in X Axis Dimension by selected one date

John, your answer was correct,

I just found out what I was doing, so let me explain why it did not work immidiately

So currently I have this expression - if(GetSelectedCount(Day)> 1,Sum(actual_turnover),Sum({<[created_date]={'>=$(=date(min(created_date)-30))<=$(=date(max(created_date)))'}>} actual_turnover))

Now the created_date = is being selected by selected a [Day], [Month], [Year] which are assiciated to the created_date HOWEVER, when I add the created_date in the report and I actually selected a particualr date, the chart displays the dates, if I select the day,month and year seperately even though they are associated to the created date, the report will only display one day.

So now I am going to find a way how to make it work with the [Day], [Month], [Year]

Thanks!

MVP
MVP

Re: date range in X Axis Dimension by selected one date

Ah, yes, you need to use set analysis to ignore every other date-related field associated with created_date.  This is normally done by listing them explicitly:

if(GetSelectedCount(Day)> 1,Sum(actual_turnover),Sum({<[created_date]={">=$(=date(min(created_date)-30))<=$(=date(max(created_date)))"},Day=,Month=,Year=>} actual_turnover))

There's also a way to tell QlikView "ignore every field in the calendar table except for created_date", but you'd probably reserve that for if there are a lot of fields in the table to be ignored.

stevegimbrollmt
Contributor II

Re: date range in X Axis Dimension by selected one date

IMPRESSIVE!

It worked, am doing more testing but it worked.  so when in set analysis you do Field=, that means, exclude those fields im selecting?

Thanks once again John

Community Browser