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: 
Not applicable

Sum of Sales for current selection with Max Date

using set analysis how can i get total sale

i want sum of sales of max date

but if i select any year then it return sum of sale of that year of max date.

if i select any month then it return sales of max date for that month

15 Replies
Not applicable
Author

With variable try this

  SUM( {1 < Date= {$(vMaxDate)}  ,  > }   Value)

Not applicable
Author

Without comma sorry

SUM( {1 < Date= {$(vMaxDate)}    > }   Value)

Not applicable
Author

giving error

tresesco
MVP
MVP

Create a sample qvw that would help us help you, because for date comparison format plays a big role as well, otherwise my suggested expression should work. Note the inclusion of '{1}' in the max().

sum({<Date={'=$(=max({1}Date))'}>} Sale)

Or,

sum({<Date={'=$(=Date(max({1}Date)))'}>} Sale)

Not applicable
Author

Inside the script you can create a variable:

 

  LET vMaxDate = peek( 'FieldData', -1, 'TableName'); 

Then you can use the variable

 

SUM({1 < FieldDate= {$(vMaxDate)}    >   }   Value)

Regards

Claudio

ashfaq_haseeb
Champion III
Champion III

Hi,

In your variable define vMaxDate = max(Date)

and try below

=sum({<Date={'$(vMaxdate)'}>} Sales)

or share your sample app.

Regards

ASHFAQ