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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with expression

Hi All,

I am trying display sale for YeartoDate(YTD) for last year.. but when i check totals with source i am getting wrong number

i guess month variable is wrong ... can some one correct me

here is my expression

sum({$<Year = {$(vLastYear)}, Month = {"<=$(vThisMonth)"}>} Sales)

Capture.JPG

4 Replies
swuehl
MVP
MVP

Hard to say what is going wrong here, but one thing that you should check:

If the user can make selections in other calendar table fields like Date, you need to clear all these fields in the set expression:

=sum({$<Year = {$(vLastYear)}, Month = {"<=$(vThisMonth)"}, Date= >} Sales)

How are the variables defined?

Not applicable
Author

LET vToday = vMaxDate;

LET vThisYear = year($(vToday));

LET vLastYear = year($(vToday)) - 1;

LET vThisMonth = num(month($(vToday)));

LET vLastMonth = num(month(addmonths($(vToday), -1)));

but when i use  below expression i get correct results

sum(if(FPYTD, Sales))

where   FPYTD is obtained by  expression     inyeartodate(D, $(vToday), -1) * -1 AS FPYTD,

Anonymous
Not applicable
Author

Since the two different tests in your expression have slightly different syntax I would try testing each part:

sum({$<Year = {$(vLastYear)}>} Sales)

sum({$<Month = {"<=$(vThisMonth)"}>} Sales)

I would use:

sum({$<TransDate = {'<$(vThisMonthLastYearStart)'}>} Sales)

with:

LET vThisMonthLastYearStart = date(monthstart(addyears($(vToday),-1)));

Not applicable
Author

Hi

Can u please attach sample app