Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Count function

Hello Everyone,

I need Your help for function Count that will show the number of Customers with positive deviation in sales between current year and last year. My expression for the calculation of this deviation is       

Sum({$<[Product Line]-={'RSC'},Year={"$(=Year(Today()))"},Month={"$(=Month(Today())-1)"}>}[Volume sqm])-Sum({$<[Product Line]-={'RSC'},Year={"$(=Year(Today())-1)"},Month={"$(=Month(Today())-1)"}>}[Volume sqm])

Robert

1 Solution

Accepted Solutions
ToniKautto
Employee
Employee

The nested aggregation might be a problem when adding the entire deviation aggregation inside the count.

It depends a bit where you want to aggregate the count. In a table column you can simply use a total function to find the count based on a if() statement. For a calculated total I would suggest looking at a Aggr() based expression. See attached QVF for example on the principle.

With the assumption that your dimensions is CustomerID, the expression could be something like:

=Count( Aggr( if( Sum({$<[Product Line]-={'RSC'},Year={"$(=Year(Today()))"},Month={"$(=Month(Today())-1)"}>}[Volume sqm])-Sum({$<[Product Line]-={'RSC'},Year={"$(=Year(Today())-1)"},Month={"$(=Month(Today())-1)"}>}[Volume sqm]) >0,1), CustomerID))

View solution in original post

3 Replies
Anonymous
Not applicable
Author

may be like this?

=count(distinct if(DeviationExpression>0, CustomerID)

ToniKautto
Employee
Employee

The nested aggregation might be a problem when adding the entire deviation aggregation inside the count.

It depends a bit where you want to aggregate the count. In a table column you can simply use a total function to find the count based on a if() statement. For a calculated total I would suggest looking at a Aggr() based expression. See attached QVF for example on the principle.

With the assumption that your dimensions is CustomerID, the expression could be something like:

=Count( Aggr( if( Sum({$<[Product Line]-={'RSC'},Year={"$(=Year(Today()))"},Month={"$(=Month(Today())-1)"}>}[Volume sqm])-Sum({$<[Product Line]-={'RSC'},Year={"$(=Year(Today())-1)"},Month={"$(=Month(Today())-1)"}>}[Volume sqm]) >0,1), CustomerID))

Anonymous
Not applicable
Author

Toni,

thanks a lot! It's works

Robert