Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to use count function with if condition

hi

I want to count year, if the distinct year = 1 , then shws the list of month , otherwise list of year.

how to make if condition,

I am using this

=

if( count(distinct YEAR)=1 ,MONTH,YEAR)

, but it is not getting sufficient output.



5 Replies
Not applicable
Author

Hi,

You can try this one

count(distinct if(YEAR=1,MONTH,YEAR))

Thanks & Regards

Not applicable
Author

Its not working

pover
Luminary Alumni
Luminary Alumni

If you make a drilldown dimension group that includes year and month you will get the behavior you want and not have to use an expression.

Regards.

maneshkhottcpl
Partner - Creator III
Partner - Creator III

Hi,

Uneed to use the aggr function while using the nested aggrigate functions.

U can use the count(if(aggr(count(distinct YEAR),YEAR)=1,MONTH,YEAR))

Or Send me sample application

Regards

MAnesh

Not applicable
Author

you can try this

Create one variable eg vCountYear and assign this

=



Count(DISTINCT Year) formula to it

After that in list box Expression use this

=

if(vcountYear=1, Month,Year)