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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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.



Labels (1)
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
Partner - Master
Partner - Master

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)