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: 
etrotter
Creator II
Creator II

Prior YTD

Hello,

I am struggling to get my Prior YTD function working:

Sum({<Date={">=$(=Num(YearStart(Max(Date))-365))<=$(=Max(Date)-365)"}>} [Billing Quantity])
/
Sum({<Date={">=$(=Num(YearStart(Max(Date))-365))<=$(=Max(Date)-365)"}>} #Units)

Please let me know what you think!

1 Solution

Accepted Solutions
sasiparupudi1
Master III
Master III

May be try

Sum({<Date={">=$(=YearStart(Max(Date),-1))<=$(=AddYears(Max(Date),-1))"}>} [Billing Quantity])

/Sum({<Date={">=$(=YearStart(Max(Date),-1))<=$(=AddYears(Max(Date),-1))"}>} #Units)

View solution in original post

6 Replies
kamielrajaram
Creator III
Creator III

Hi,

You can set 2 variables

vPreStartDate = Date(YearStart(Max(addmonths(Date,-12))))

vPreEndDate = Date(addmonths(Max(Date),-12))

and make your expression as

Sum({<Date={">=$(vPreStartDate )<=$(vPreEndDate )"}>} [Billing Quantity]

/

Sum({<Date={">=$(vPreStartDate )<=$(vPreEndDate )"}>} [#Units])


Regards

Kamiel

Anil_Babu_Samineni

You can try this? If Date field is in number format, Then below works

Sum({<Date={">=$(=Num(AddYears(Max(Date)),-1))<=$(=Max(Date))"}>} [Billing Quantity])
/

Sum({<Date={">=$(=Num(AddYears(Max(Date)),-1))<=$(=Max(Date))"}>} #Units)


If Date format is in Date Format, Then this?


Sum({<Date={">=$(=Date(AddYears(Max(Date)),-1))<=$(=Max(Date))"}>} [Billing Quantity])
/

Sum({<Date={">=$(=Date(AddYears(Max(Date)),-1))<=$(=Max(Date))"}>} #Units)


Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
shiveshsingh
Master
Master

May be this

Sum({<Date={">=$(=Date(AddYears(Max(Date),-1)))<=$(=Max(Date))"}>} [Billing Quantity])
/

Sum({<Date={">=$(=Date(AddYears(Max(Date),-1)))<=$(=Max(Date))"}>} #Units)



Anonymous
Not applicable

May be this

=Sum({<Date={">=$(=YearStart(Max(Date),-1))<=$(=Date(Max(Date)),-365)"}>} [Billing Quantity])/

=Sum({<Date={">=$(=YearStart(Max(Date),-1))<=$(=Date(Max(Date)),-365)"}>} #Units)

sasiparupudi1
Master III
Master III

May be try

Sum({<Date={">=$(=YearStart(Max(Date),-1))<=$(=AddYears(Max(Date),-1))"}>} [Billing Quantity])

/Sum({<Date={">=$(=YearStart(Max(Date),-1))<=$(=AddYears(Max(Date),-1))"}>} #Units)

pawwy1415
Creator III
Creator III

Hi,

Try this one.This should work.

Sum({<Date={">=$(=Date(YearStart(max(Date-1),'MM/DD/YYYY')) <=$(=Date(AddYears(max(Date),-1),'MM/DD/YYYY'))"}>} [Billing Quantity])

/ Sum({<Date={">=$(=Date(YearStart(max(Date-1),'MM/DD/YYYY')) <=$(=Date(AddYears(max(Date),-1),'MM/DD/YYYY'))"}>} #Units)