Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
LW_18
Contributor II
Contributor II

Expression in line chart to show cumulative totals to date for current year only when plotting multiple years

I'm using a Vizlib line chart to show cumulative totals across three years, however the chart is plotting the current year values for future months which looks unsightly (see example image, unsightly part highlighted in red). 

LW_18_0-1692798195803.png

I'm using three separate expressions, one for each year.  My question is, how can I use the expression for the current year to plot values up to the current month only and stop it plotting future months as it has done above?  I've popped the expression below, I'm sure there's a pretty simple answer to this.  

Count({<[FinYear] = {'FY2324'}>}[ID])

Thanks in advance for your help 🙂

 

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer

Adjust it to: 

Count({<[FinYear] = {'FY2324'}
,[Date] = {"<$(=Today())"}
>}[ID])

View solution in original post

6 Replies
marcus_sommer

You may try to add a boolean check to your expression, something like:

Count({<[FinYear] = {'FY2324'}>}[ID]) * -(Period<=max(Period))

whereby Period is your X axis or an appropriate related calendar-field and if there are any future periods, for example for budget-values you would need to add a set analysis to the max(), like: ... Sales = {"*"} ... or similar.

 

LW_18
Contributor II
Contributor II
Author

Thank you, I'm not sure I quite understand.  I was hoping something simple like the expression below might solve the problem, however this just returns 0.

Count({<[FinYear] = {'FY2324'}
,[Date] = {'<Today()'}
>}[ID])

LW_18_0-1692887418058.png

 

marcus_sommer

Adjust it to: 

Count({<[FinYear] = {'FY2324'}
,[Date] = {"<$(=Today())"}
>}[ID])

LW_18
Contributor II
Contributor II
Author

Thank you that's worked.  For the previous years I'm trying to do exactly the same thing, how would I add in the part that says do the same but minus one year?   I've tried adding in the following but it doesn't work, what am I doing wrong?

Count({<[FinYear] = {'FY2223'}
,[Date] = {"<$(=Today()-365)"}
>}[ID])

 

Thanks

marcus_sommer

Ideally is each (period) field which is used in a matching/calculation a pure number. It avoids all formatting and conversion stuff and enables the possibility to subtract/add any offset-values and/or returning min/max-values and so on. This doesn't mean that you couldn't use string-representations of these fields within your objects or selections. If they are wanted just double the fields and adjust them appropriate.

Beside this I suggest to do the essential work already within the script by flagging YTD / LYTD and similar flags within the calendar. Mostly it's quite easy and by a financial year you will probably need to the appropriate offset-value between the year-start of normal calendar and from your financial calendar.

Many more information about this matter could you find here:

How to use - Master-Calendar and Date-Values - Qlik Community - 1495741  

LW_18
Contributor II
Contributor II
Author

Thank you 🙂