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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to get Sum of multiple dates in addmonth or Add year function

Hi Team,

i use below expression for get sum of sales at select date vs same day as last year

=num(sum({1<U_SalesDate = {"$(=date(Addmonths(U_SalesDate,-12,0),'DD/MM/YYYY h:mm:ss TT'))"}>}

U_Value),'##0.00')

but its work only single day its not working with multiple date selection in calendar input field.

Kindly solve this

Regards

SASIKUMAR

1 Solution

Accepted Solutions
Kushal_Chawda

Please check the variables , I have created on front end.

Capture1.JPG

Capture.JPG

View solution in original post

14 Replies
Kushal_Chawda

try this

=num(sum({1<U_SalesDate = {"$(=date(Addmonths(max(U_SalesDate),-12,0),'DD/MM/YYYY h:mm:ss TT'))"}>}

U_Value),'##0.00')

Anonymous
Not applicable
Author

hi ,

i already try this but its also return only single prior date, not two or more dates.

Ex:

if i select 15.01.15 in calendar its return 15.01.14

and i select 15.01.15 & 16.01.15 in calendar its return only 16.01.14. not sum of both dates

Kushal_Chawda

So when you select the 15.01.15 & 16.01.15, which dates sum you want? and when you select single date which date sum you want? Please clarify

Anil_Babu_Samineni

May be this?

=num(sum({1<U_SalesDate = {">=$(=date(Addmonths(max(U_SalesDate),-12,0),'DD/MM/YYYY h:mm:ss TT')) <= $(=date(Max(U_SalesDate)))"}>} U_Value),'##0.00')

Or Can you let us know which dates you want to sum when you selected two dates at a time, Pelase

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
Anonymous
Not applicable
Author

if i select 15.01.15 i want  sum of 15.01.14

and if select 15.01.15 & 16.01.15 & more date , i need to return sum of past year dates like (15.01.14 & 16.01.14 & more date) both dates

Anonymous
Not applicable
Author

if i select 15.01.15 i want  sum of 15.01.14

and if select 15.01.15 & 16.01.15 & more date , i need to return sum of past year dates like (15.01.14 & 16.01.14 & more date) both dates

Kushal_Chawda

create variable

vDateRangeCount = if(getselectedcount(Date)<=1,0,getselectedcount(Date))

num(sum({1<U_SalesDate = {">=$(=date(Addmonths(max(U_SalesDate),-12,0)-$(vDateRangeCount),'DD/MM/YYYY h:mm:ss TT'))<=$(=date(Addmonths(max(U_SalesDate),-12,0),'DD/MM/YYYY h:mm:ss TT'))"}>}

U_Value),'##0.00')

aniketsr
Creator
Creator

Kitna points jama Karega

Anil_Babu_Samineni

if i select 15.01.15 i want  sum of 15.01.14

May be this?

Sum({<U_SalesDate = {"$(=AddYears(U_SalesDate,-1))"}>} U_Value)

and if select 15.01.15 & 16.01.15 & more date , i need to return sum of past year dates like (15.01.14 & 16.01.14 & more date) both dates

It will work same if you mentioned same in expression

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