Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
DutchArjo
Creator
Creator

How to create YTD's (and MAT's) and create the chart as shown?

I've been trying all day to create YTD perios in order to create a chart showing figures compared over the current year period. I'm used to having YTD's in my data and simply adding them to my chart in Excel but in Qlik, I can't seem to work this out.

 

Below is how I would have it created in Excel:

YTD.PNG

This makes an easy year on year comparison possible.

But how can I get ytd's and add them to a grouped bar chart like above AND have these refreshed automatically upon a new data load?

 

I' ve been puzzling with expressions for dimensions in the chart but that didn't work out, I tried to add a variable containing the YTD (add wanting to add YTD-1 and YTD-2 later on).

Labels (4)
6 Replies
marcus_sommer

Just create an appropriate YTD flag within the calendar, for example like:

-(daynumberofyear(DateField)<=daynumberofyear(today())) as YTD

and then you could use year as dimension in the chart and an expression like:

sum({< YTD = {1}>} Value)

DutchArjo
Creator
Creator
Author

I don't have the option to create these in most of the apps/dashboards but I can for my own apps.

I was able to create what I wanted for a separate chart (but doing so for each individual chart is not very efficient):

YTD.PNG

using this set analysis expression:

Sum({$<[%VL_Jaar]={"$(=Year(Today()))"}, [%VL_Maand]={"<=$(=num(Month(Today())))"}, [%VL_Dag]=,[%VL_Datum]=,[%VL_Jaarmaand]=,%VL_> }[ATNL_GRC statushouders PP+vbt])

(and adjusting %VL_Jaar for YTD-1 and YTD-2 with Year(Today()-1) and Year(Today()-2))

 

 

 

marcus_sommer

A single calendar for ALL applications is enough - and then each other application just picked the wanted fields and periods. It couldn't be more simple.

DutchArjo
Creator
Creator
Author

of course that would be the best. I will ask the IT department if its possible to get these.

For now, I need to make them myself. YTD's can be added, though I want to add the year name to the description as 5 ytd's are possible (I have max 5 years of date).

this is what I use for the YTD now:

Sum({<[%VL_Jaar]={"$(=Year(Today()))"}, [%VL_Maand]={"<=$(=num(Month(Today())))"}, [%VL_Dag]=,[%VL_Datum]=,[%VL_Jaarmaand]=> }[ATNL_GRC statushouders PP+vbt])

(and adjusting the year number for each ytd)

I have been trying to get MAT's in the same chart. However am I running in some trouble. I created the expression below:

<[%VL_Jaarmaand]={">=$(=(Year(Today())-1)*100+(Month(Today())))<=$(=(Year(Today())*100+Month(Today())-1))"}

 

Where the expression seems to be correct:

MAT.PNG

but doesn't return anything (nothing in purple here):

MAT.PNG

Is there something missing in the set analysis?

edit: Found it. I've loaded the %VL_JaarMaand with a dash between year and month. I removed that from the load script and now the MAT functions are working as expected:

MAT.PNG

 

Although I was told I could easily achieve almost the same for every month in a chart using the accumulate option for the measure/bar height and '12 steps':

MAT.PNG

marcus_sommer

In this set analysis you create numeric periods of YYYYMM which are not reflecting a YTD approach else it goes to rolling periods of the last 12 months ...

You may consider to transfer the above suggested YTD creation-logic into the UI, maybe with something like:

if(daynumberofyear(DateField)<=daynumberofyear(today()), sum(MyValue))

and then using the year-field as dimension.

DutchArjo
Creator
Creator
Author

I will look into it.


 I know, it made a split between YTD and MAT. The rolling 12 months is for the moving annual total I also wanted.