Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

gnunziante
New Contributor

Count distinct on a if-variable condition

Hi,

I need some help to set a formula.

I have a variable, vStock, that calculate the items stock at a given date:

SUM({$<StockDate={">=$(=MIN(DateInit))"}>*$<StockDate={"<=$(=MIN(DateEnd))"}>} Quantity )

I'm trying to count the distinct items where stock is greather than zero, for example:

COUNT DINTINCT [Item] WHERE [vStock]>0

After some research I find out this formula, but is very slow (and I don't know if it is correct):

COUNT(DISTINCT AGGR(if($(vStock)>0, Item), Item))


There is another, simple way to calculate this without Aggr and/or If statement?

1 Reply
thiago_justen
Valued Contributor III

Re: Count distinct on a if-variable condition

Gabriele,

What about this:

Count({<ITEM={"=$(vStock)>0"}>} Distinct ITEM)


Cheers

Thiago Justen Teixeira Gonçalves
WhatsApp: 24 98152-1675
Skype: justen.thiago
Community Browser