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

Announcements
Join us at Qlik Connect 2026 in Orlando, April 13–15: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
bd_USTX
Contributor II
Contributor II

Set Analysis - Sum of Prior YTD

Hello, 

I am relatively new to Qlik Sense, having started learning earlier this year. 

I am having trouble with set analysis to calculate the sum for the prior YTD amount. I've tried several solutions that I've found on the forums here, but I'm still doing something wrong. 

Very simply, my data has a BillDate dimension - loaded as "Date#(BillDate) as BillDate".There is a dollar amount for each of these BillDate records. 

bd_USTX_3-1661715885307.png

 

To get the YTD total for last year, I have been trying with the following expression:

SUM({$<BillDate = {'>=$(=Date(AddYears(YearStart(Today()),-1)))<$(=Date(AddYears(Today(),-1)))'}>}Amount)

But while the expression checker evaluates the set analysis correctly, I get  back every time.

bd_USTX_1-1661715570794.png

I have tried using variables to get the dates, and using those variables in the set analysis - with the same result. 

I have gone through date formatting, making sure my dates are all formatted the same across the app. The dates are the same format after my load, as they appear in the set analysis. 

bd_USTX_2-1661715741843.png

I'm at a loss and have somehow managed to kill most of my day with this. 

Any suggestions are greatly appreciated! 

 

Labels (2)
1 Solution

Accepted Solutions
BrunPierre
Partner - Master II
Partner - Master II

You may have to format the date appropriately as it's sometimes interpreted differently. And use the modified expression below.

Date(BillDate,'DD/MM/YYYY') AS BillDate,

Sum({< BillDate ={">=$(=YearStart(Max(BillDate), -1))<=$(=AddYears(Max(BillDate), -1))"}>} Amount )

peter_brown_2-1661731808199.png

 

 

 

 

 

View solution in original post

6 Replies
BrunPierre
Partner - Master II
Partner - Master II

Try this Last YTD for the period selected

Sum({<Year=, Quarter=, Month=, Week=, BillDate ={‘>=$(=YearStart(Max(BillDate ), -1))<=$(=AddYears(Max(BillDate ), -1))’}>} Amount)

bd_USTX
Contributor II
Contributor II
Author

Thanks for your reply! I must be doing something wrong still. Qlik doesn't recognize "Quarter", and using any of the others still returns 0. I tried omitting the "Quarter" piece, and still get a back. 

bd_USTX_0-1661718469967.png

The expression checker still evaluates the date range piece correctly. 

bd_USTX_2-1661718618886.png

I added a copy of my app, if that helps. 

 

BrunPierre
Partner - Master II
Partner - Master II

Perhaps this if you haven't derived time dimensions.

Sum({<BillDate ={‘>=$(=YearStart(Max(BillDate ), -1))<=$(=AddYears(Max(BillDate ), -1))’}>} Amount)

bd_USTX
Contributor II
Contributor II
Author

Still coming up with 0, I'll have to spend some more time with this and add time dimensions to the load script and try again. Thanks for your advice!! 

Very simple app, trying to practice YoY, MoM measures with it - served its purpose though, because now I see what needs to be done.

BrunPierre
Partner - Master II
Partner - Master II

You may have to format the date appropriately as it's sometimes interpreted differently. And use the modified expression below.

Date(BillDate,'DD/MM/YYYY') AS BillDate,

Sum({< BillDate ={">=$(=YearStart(Max(BillDate), -1))<=$(=AddYears(Max(BillDate), -1))"}>} Amount )

peter_brown_2-1661731808199.png

 

 

 

 

 

bd_USTX
Contributor II
Contributor II
Author

That did it! Thanks so much for your help!!!!!