Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
New Contributor

aggregate by maximum year in dataset


I have been following the forum questions on using set expressions and $-sign expansions to aggregate a field where it meets a particular condition.

For example, I want to count the number of IDs for the latest/maximum year in dataset. I wrote the following script:

count({<current_year={'$(=Max(Date(Date#(Year(date#),'YYYY')), 'YYYY'))'}>}id)

but it returns the count of ids across all years (there are two years of data in my data set) instead of max year.

I have field called year# and date# in my data set.

What I also don't  understand that for my code to return a number, I have to create this current_year variable. I assumed that logically the code be written so  that that year# equals the max year value, the count of ids, like this.

count({<year#={'$(=Max(Date(Date#(Year(date#),'YYYY')), 'YYYY'))'}>}id)

I am new to the Qlik community and have gone through related posts, but still confused by my code behavior.

Any help is appreciated.

Tags (3)
2 Replies

Re: aggregate by maximum year in dataset

May be you places wrong place/? May be just this


Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Honored Contributor

Re: aggregate by maximum year in dataset

may be this

=count({<Year = {'$(=max(Year(DateField))'}>}Ids)