# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Contributor

## # of months with positive returns

Hello all,

I am trying to setup a KPI with the number of months in my history that had a positive result.

The total number of months in the data set was easy: Count([MonthStartDate.autoCalendar.YearMonth]) which returned the correct number (203).

Now I'd like to add two more KPIs.  One for the number of months with a positive return, one for the number of months with a negative return.

I tried: if(PA_Active>0,Count(PA_Active)) but that did not work.  it returns a "-"

Any ideas?

Thanks for the help.

Olivier

1 Solution

Accepted Solutions
Contributor

## Re: # of months with positive returns

Hi Chanty,

This almost worked.  Fiddled with it a bit and found that it worked like this:

=count(if(PA_Active<0,PA_Active))

Thanks for the help

7 Replies
Esteemed Contributor III

## Re: # of months with positive returns

try this

=count(if(PA_Active>0,PA_Active),PA_Active)

Honored Contributor II

## Re: # of months with positive returns

maybe this:

Sum( Aggr( if( PA_Active>0, Count(PA_Active), 0 ), [MonthStartDate.autoCalendar.YearMonth] ) )

Honored Contributor III

## Re: # of months with positive returns

TRy

Count( {<PA_Active {">0"}>}PA_Active) - - -  For Posititve

Count( {<PA_Active {"<0"}>}PA_Active) - - -  For Negative

Contributor

## Re: # of months with positive returns

Hi Chanty,

This almost worked.  Fiddled with it a bit and found that it worked like this:

=count(if(PA_Active<0,PA_Active))

Thanks for the help

Contributor

## Re: # of months with positive returns

thanks for this.  I tried it but it gave me an error message.  I'm going to use the simpler formula hinted at by Chanty above.

Cheers,

Olivier

Honored Contributor III

## Re: # of months with positive returns

Yes I Missed '=' sign.

Count( {<PA_Active = {">0"}>}PA_Active) - - -  For Posititve

Count( {<PA_Active = {"<0"}>}PA_Active) - - -  For Negative

Esteemed Contributor III

## Re: # of months with positive returns

good  it worked for you.