Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
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.
May be you places wrong place/? May be just this
count({<year#={'$(=Max(Year([date#])))'}>}id)
may be this
=count({<Year = {'$(=max(Year(DateField))'}>}Ids)