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: 
sat_tok52
Creator
Creator

YTD Select Based On the Month Selection

Hi All,

As per my requirement YTD select based on the month selection i.e , suppose  if the user select March month the YTD data should show data from jan-01-2019 to Mar-31-2019 and if user has selected Jan Month then data should show Jan-01-2019 to Jan-31-2019 and No Selection,then data should show from Jan-01-2019 to till date.

Any Help.

 

Thanks.

 

 

 

 

Labels (1)
2 Replies
colinh
Partner - Creator II
Partner - Creator II

The most flexible way of doing this is to create a numeric PeriodNo for comparisons.  In your load script, create a field something like:

autonumber(monthname(Date)) as PeriodNo,

and make sure to order by Date.

Then in your expression you can get YTD by doing:

=sum({$<[Year]={$(=max([Year]))}, Month=, PeriodNo={"<=$(=(max(PeriodNo)))"} >} [#Sales])

Having PeriodNo means you can easily do YTD, compare one month to the previous month, compare 12 months to the previous 12 months, etc.

Vegar
MVP
MVP

You don't need PeriodNo to achieve this, you can use Month if you defined it by the Month() function. If so it is an dual containing both a numeric and a string value.

Try: Sum({$<[Year]={$(=max([Year]))}, Month={"<=$(=(max(Month)))"} >}ValueField)

clipboard_image_0.png