# Qlik Sense App Development

New Contributor III

## Set Analysis - Two or more values in a variable

I have the below formula for Invoice count.

There is a filter bar on the top of the page which has [Year Month] and other filters. If there is no selection in [Year Month]; the below formula shows the information for the current month. (Line No1).

When there is a selection in [Year Month] let say Jan-2017, the formula shows the value for that month. (Line 2).

What changes I have to make in the below formula so that it shows data for multple selection in [Month Year] filter. Let say Jan-2017 and Feb-2017 and more.

If(getselectedcount([Month Year])<1,

Count({\$<[YearMonth No]= ,[Year] = ,[Month No]=,[Month Year]=,[Month]=,[MonthID]= {"\$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}>} [Invoice No])

,

Count({\$<[YearMonth No]= ,[Year] = ,[Month No]=,[MonthID]=,[Month]=,[Month Year]= {"\$(=getfieldselections([Month Year]))"}>} [Invoice No])

)

5 Replies
Esteemed Contributor III

## Re: Set Analysis - Two or more values in a variable

I think it will work if you simplify the second line, give it a try:

...

Count({\$<[YearMonth No]= ,[Year] = ,[Month No]=,[MonthID]=,[Month]=>} [Invoice No])

...

New Contributor III

## Re: Set Analysis - Two or more values in a variable

this brings the count for all. Not what is required.

Esteemed Contributor III

## Re: Set Analysis - Two or more values in a variable

Saying "second line" I mean your 2nd expression i the if() statement.  The full expression will be:

If(getselectedcount([Month Year])<1,

Count({\$<[YearMonth No]= ,[Year] = ,[Month No]=,[Month Year]=,[Month]=,[MonthID]= {"\$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}>} [Invoice No])

,

Count({\$<[YearMonth No]= ,[Year] = ,[Month No]=,[MonthID]=,[Month]=>} [Invoice No])

)

I also assume that the filter [Year Month] and the field [Month Year] in the if() condition is the same field, just a typo in your opening post (?)

MVP

## Re: Set Analysis - Two or more values in a variable

Why not just use

Count( [Invoice No])

in the else branch of your if() function? What should the set analysis do other than the selections would do anyway?

MVP

## Re: Set Analysis - Two or more values in a variable

Still facing issue, Can you elaborate more. If Jan-2017 selection happened what is the output you want to show?