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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
AlphaNik
Contributor
Contributor

Count for max date in a month

Hi everyone, 

I have a fact table with a unique id, a date and month name.

ex:

fact_id fact_date fact_monthName
1 21/01/2025 jan 25
2 31/01/2025 jan 25
3 07/02/2025 feb 25

 

I would like to write an expression to count my fact, but only for the last possible date of every month (based on current selection). in my example, if year 2025 would be selected, I should count id #2 for january and #3 for february.

I tried something like this:

=count( {<fact_date={"=aggr(max(fact_date), fact_monthName)"}>} distinct fact_id)

The expression is read, so it seems correct syntax wise, but the values are not what I expected. It seeems to count values for different dates.

Any help?

 

Thanks

 

 

 

Labels (1)
1 Solution

Accepted Solutions
JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @AlphaNik 

 

Try this 

count( {<fact_date={"=fact_date=aggr(max(fact_date), fact_monthName)"}>} distinct fact_id)

Let me know 

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn

View solution in original post

3 Replies
JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @AlphaNik 

 

Try this 

count( {<fact_date={"=fact_date=aggr(max(fact_date), fact_monthName)"}>} distinct fact_id)

Let me know 

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn

AlphaNik
Contributor
Contributor
Author

Thank you, it worked.

Only thing, i had to create a temp table in order to order by date. For some reason it seems the value for aggr is evaluated only for the first row in load order (with monthName as a dimension). I tried to play with order by clause inside aggr to no avail. 

 

Anyway it's working!

Regards Nik

JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @AlphaNik 

Great news! Im also struggling on an aggr sort. Should post something soon for other people to help me on this one! 

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn