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: 
Sidimar
Contributor
Contributor

How can I sum all records by a specific date entered by the user filter

Good morning everyone, all right?
As stated in the subject, I need to sum all records until a specific date. I found a way to do this at this link.

https://community.qlik.com/t5/QlikView-Creating-Analytics/How-can-i-sum-all-records-until-a-specific...

But there is a detail, the date cannot be predefined, it needs to be informed by the user through the filter.
When the date is entered, it must be used as the maximum date; otherwise, The most recent date must be taken into consideration. How to proceed?
Thank you very much in advance.

1 Solution

Accepted Solutions
treysmithdev
Partner Ambassador
Partner Ambassador

I think you are misunderstanding the solution you linked. This solution is dynamic to what date the user selects, there is no predefined date value.

 

In this formula: 

 

sum({$<Date= {"<=$(=max(Date))"}>} Amount)

 

 Date is a field. 

That means the max date value possible in the field Date will be the limit. 

Say you have these date values:

Date
01/01/2019
01/09/2019
01/17/2019
01/31/2019
 02/01/2019

 

With no selections the above expression will evaluate to:

 

sum({$<Date= {"<=02/01/2019"}>} Amount)

 

This would sum values 01/01/2019 - 02/02/2019

 

If a user selects '01/31/2019' in the filter, the expression would then evaluate to:

 

sum({$<Date= {"<=01/31/2019"}>} Amount)

 

This would sum values 01/01/2019 - 01/31/2019

 

Blog: WhereClause   Twitter: @treysmithdev

View solution in original post

2 Replies
treysmithdev
Partner Ambassador
Partner Ambassador

I think you are misunderstanding the solution you linked. This solution is dynamic to what date the user selects, there is no predefined date value.

 

In this formula: 

 

sum({$<Date= {"<=$(=max(Date))"}>} Amount)

 

 Date is a field. 

That means the max date value possible in the field Date will be the limit. 

Say you have these date values:

Date
01/01/2019
01/09/2019
01/17/2019
01/31/2019
 02/01/2019

 

With no selections the above expression will evaluate to:

 

sum({$<Date= {"<=02/01/2019"}>} Amount)

 

This would sum values 01/01/2019 - 02/02/2019

 

If a user selects '01/31/2019' in the filter, the expression would then evaluate to:

 

sum({$<Date= {"<=01/31/2019"}>} Amount)

 

This would sum values 01/01/2019 - 01/31/2019

 

Blog: WhereClause   Twitter: @treysmithdev
Sidimar
Contributor
Contributor
Author

Thank you very much, I really got it wrong when I implemented that it wasn't working. Now yes, thank you very much;