Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
khaycock
Creator
Creator

Year-to-date flags on selection

Is there anyway to make an expression that is based on the selection of the year?

At the moment, I have expressions that include variables for current year-to-date and prior year-to-date so they show data for 2018 and 2017. But i have data going back other years that would be good to see year-on-year for so depending on the selected year, I would want to see the year-to-date for that year and then the year-to-date for the year before.

Is that possible?

6 Replies
sunny_talwar

Year to date when year is selected will be the whole year, right?

MK_QSL
MVP
MVP

I think you have used Today() in your YTD and LYTD expressions.

Just replace Today() with user selected dates... i.e. Max(YourDateField)

Something like below..

YTQ, QTD, MTD and WTD

Date Level Analysis - WTD, MTD, QTD & YTD (Current Year & Previous Year)

YTD,QTD,MTD,WTD IN Qlik Sense

jonathandienst
Partner - Champion III
Partner - Champion III

Use set expressions with syntax along these lines

          {<Year = {'$(=Max(Year))'}, ... >}

          {<Year = {'$(=Max(Year)-1)'}, ... >}


You may need to override the actual selection, if you are making date selections in fields other than year. Max() will produce the latest (current) year when nothing is selected, or the selected year if when a selection is made.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
avinashelite

In your case set the YTD for all the years base on the date and use the addyear() function mark the required year to date

khaycock
Creator
Creator
Author

But I was thinking that I would need an expression to have a year-to-date based on the month picked so if March

But I think I need an expression that shows YTD regardless of the year clicked so at the moment its 2018 and 2017 but if 2015 was selected then it needs to show that instead? Does that make sense?

sunny_talwar

So, in that case a front end set analysis based expression is the way to go... Manish shared links where you can look at the set analysis that can be used