Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
sai_yashwan
Contributor
Contributor

count of MAX record for dynamically changing the date variables

I have a requirement to display max  records between the date range (changes dynamically)

Attache the data 

 

This expression gives everything out there. however, I need to display the latest record within the selected date range 

forex, if the user selects the date range '20181019' to '20190415', I need  Benefitrnk =  4 only be counted.

=Count(distinct if( Case='BV' and Case_Status='Completed' and Date ='CaseCreatedDate' and (CalendarDate>='20181023' and CalendarDate<='20190305' ) , Profile_ID))

Any insight would help me. Many thanks for considering my request. 

Sai.

3 Replies
edwin
Master II
Master II

a bit confusing looking at the data, because for 20190415, Benefitrnk is 3 not 4. 

if you want to count only the data set where date is max of the selected range, you can create a variable

vMaxDate=max(Date)

=Count(distinct if( Case='BV' and Case_Status='Completed' and Date ='CaseCreatedDate' and (CalendarDate='$(vMaxDate)' ) , Profile_ID))

but i suggest using set analysis:

=Count(distinct {<Case={'BV'},Case_Status={'Completed'},Date ={'CaseCreatedDate'},CalendarDate={'$(vMaxDate)'}>} Profile_ID))

  

sai_yashwan
Contributor
Contributor
Author

Thanks, Edwin, Appreciate the response!

But the requirement is that dates are dynamically changing based on the user selection calendar icons for start and from dates.. so I need the max value between a start and end dates...CalendarDate>='$(vStartDate)' and CalendarDate<='$(vEndDate)' ..so I tried to modify the logic to pull the max count but its not working ..can you help?

Brett_Bleess
Former Employee
Former Employee

About the best I have is the following Design Blog area base link, search around there and see if you can find any posts that may help you with things.  I generally start with a single word, see what pops up, and then rework or narrow down from there until I find something that looks interesting.  What you may have going on with variables is a potential timing issue, just FYI that is causing an issue in that the expression is calculating before the variables are updated etc.  One potential snag I can see here depending upon how things are setup to populate.  This will kick things back up too, so maybe someone else will have a look too.

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.