Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count number of conditions

Hi Everyone,

I am having some problems to get the next data:

I have a shop with three registers, In two of thems A is bigger than B and in one of them no. What I want to do is a sum of the number of registers where A is bigger (2). The thing is that if I have the dimension date (dia) selected it does the sum correctly  2.

Dimension.PNG.png

However, when I Delete the dimension date, which I do not want to show, it gives me 0 and no 2, which is the figure wchich I am searching for.

withoutdimension.PNG.png

Thank you.

Best regards.

1 Solution

Accepted Solutions
maxgro
MVP
MVP

sum(if(aggr(sum(a)-sum(b),shop,dia)>0,1,0))

View solution in original post

5 Replies
alexandros17
Partner - Champion III
Partner - Champion III

It is because the dia field split your data into different rows, if you want the same result you have to aggr by shop and dia

Not applicable
Author

when aggregating =if(A>b,aggr(count(shop),dia,0)) it gives me a hyphen.

Thank you Alessandro.

maxgro
MVP
MVP

sum(if(aggr(sum(a)-sum(b),shop,dia)>0,1,0))

Not applicable
Author

Thank you so much Massimo, It is perfect as you write.

maxgro
MVP
MVP

When you think you get the answer, please close this discussion by giving Correct and Helpful answers to the posts which are useful for you.  It helps others in finding answers for similar scenarios. Thanks and good Qlik.