Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

drno811sf
New Contributor II

How do I set a static filter on a chart to only show the information for a max date?

I've found some things indicating I need to do set analysis, and even found some syntax, but the challenge I'm running into is that my date field is in the format YYYY-MM.  I think that makes it a text field, and I believe using the max function isn't working properly.  Does anyone know how to do the syntax so that I can set an expression to only return the results for the max date?

Here are the two attempts I've made so far (but I think I might be getting some Qlikview syntax mixed in here....I'm really new to this, so the syntax is a challenge for me):

=Sum({<[Year-Month] = {"$(=Max([Year-Month])"}>}Count)

=sum({<[Year-Month]={'=(max([Year-Month]))'}>}Count)

3 Replies

Re: How do I set a static filter on a chart to only show the information for a max date?

Did you may be missed a parenthesis in your first expression?

=Sum({<[Year-Month] = {"$(=Max([Year-Month]))"}>}Count)

If you think that your Year-Month is not read as date, I would suggest you to make it read as a date in the load script like this

Date(Date#([Year-Month], 'YYYY-MM'), 'YYYY-MM') as [Year-Month]

and then try this

=Sum({<[Year-Month] = {"$(=Date(Max([Year-Month]), 'YYYY-MM'))"}>}Count)

drno811sf
New Contributor II

Re: How do I set a static filter on a chart to only show the information for a max date?

Thanks!  I took a different approach and created a Date Sort Key that was Year*12+Month so that I could use the max function without having to mess with date formatting.

This worked for me:

=Sum({<[Date Sort Key] = {"$(=Max([Date Sort Key]))"}>}Count)

Re: How do I set a static filter on a chart to only show the information for a max date?

Yup, that's another way to do it...

Community Browser