1 Reply Latest reply: Jan 27, 2018 6:44 AM by Thiago Justen Teixeira RSS

    Count distinct on a if-variable condition

    Gabriele Nunziante


      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?