Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik_UserEM
Contributor
Contributor

Set Analysis -YTD Through Prior Full Month

Hello,

I am trying to created a dynamic YTD sales calculation through the prior full month based on a Year-Month selection.

I currently have this formula, however, when I select 2021-May it is still showing the sales for May as well:

SUM({<Year={'$(vMaxYear)'},%DATE_KEY={'<$(vMaxMonthStart)'},Month=,%DATE_KEY=,[Year-Month]=>}Sales)

%DATE_KEY = sales order date

vMaxYear = current year (2021)

vMaxMonthStart = start of the max month (5/1/2021)

What am I doing wrong?

1 Solution

Accepted Solutions
JuanGerardo
Partner - Specialist
Partner - Specialist

Hi @Qlik_UserEM, I am seeing a couple of things to check:

  • When comparing and not filtering an exact value, you must use double quotes.
  • Field %DATE_KEY is used twice in the filtering with different criteria

You can try:

SUM({<Year={'$(vMaxYear)'},%DATE_KEY={"<$(vMaxMonthStart)"},Month=,[Year-Month]=>}Sales)

And sometimes the date format can make your filter not work, so you can also try Date(vMaxMonthStart, 'MM/DD/YYYY') (use your default date format) instead of vMaxMonthStart as a second try.

 

JG

View solution in original post

2 Replies
JuanGerardo
Partner - Specialist
Partner - Specialist

Hi @Qlik_UserEM, I am seeing a couple of things to check:

  • When comparing and not filtering an exact value, you must use double quotes.
  • Field %DATE_KEY is used twice in the filtering with different criteria

You can try:

SUM({<Year={'$(vMaxYear)'},%DATE_KEY={"<$(vMaxMonthStart)"},Month=,[Year-Month]=>}Sales)

And sometimes the date format can make your filter not work, so you can also try Date(vMaxMonthStart, 'MM/DD/YYYY') (use your default date format) instead of vMaxMonthStart as a second try.

 

JG

Qlik_UserEM
Contributor
Contributor
Author

Thank you, this worked perfectly.