Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

josephinetedesc
Contributor III

automate the chart to show THIS months date

Hi I have a chart with the x axis being the daily date. As I have years of data - this looks messy and some people do not like to "click".

Is there someway that the date can default to today's Month when a patient clicks on the daily chart???

I would prefer a simple way of doing this

Jo

6 Replies
kamal_sanguri
Valued Contributor

Re: automate the chart to show THIS months date

yes, absolutely.. It is very simple.. you just have to replace the your current date field from your chart's dimension and use a calculated dimension  instead of that.


=if(Month(Today())=Month(Date),Date(Date,'DD-MM-YYYY'),NULL())


Please refer the attached Qlikview Document.

MVP
MVP

Re: automate the chart to show THIS months date

That's OK if the data set is small, but may perform badly if you have millions of rows in your fact table. You also will be unable to select a different date for the chart/table. I would use a set expression of the form:

=Sum({<Date = {'$(=Date(Max(Date)))'}>} Amount)

This means use the most recent date if nothing is selected, or track the selection when the user selects a date.

Optionally - you can put the max date expression into a globally evaluated variable, like (in your load script):

Set vMaxDate = '=Date(Max(Date))';

And then use the slightly simpler:

=Sum({<Date = {'$(vMaxDate)'}>} Amount)


Adjust the expressions to suit your data model and requirements.

josephinetedesc
Contributor III

Re: automate the chart to show THIS months date

Hi All

so what I want is that instead of the daily - appearing like this - I want it to default to THIS Month.

Jo

fred.PNG

kamal_sanguri
Valued Contributor

Re: automate the chart to show THIS months date

As mentioned earlier, please try replacing your date field from dimension and replace with this one

=if(Month(Today())=Month(Date),Date(Date,'DD-MM-YYYY'),NULL())


Where Date is the Date field in your data.


josephinetedesc
Contributor III

Re: automate the chart to show THIS months date

this works:

=if(monthname(Today())=Monthname(thisDate),SUM(band1), sum(band1)) (etc for each band)

and make dimension1: =date(thisDate,'DD/MM/YYYY')

I could actually use:

=if(monthname(Today())=Monthname(thisDate),SUM(band1))) (etc for each band)



Capture2.JPG

josephinetedesc
Contributor III

Re: automate the chart to show THIS months date

I could not get this to work!

Community Browser