Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Morgoz
Contributor III
Contributor III

Clarify formula with equals Aggr ( = Aggr).

Hello,

could someone please teach me what does this measure formula does?

-SumBase = Aggr(NoDistinct Max(Base), Contra))

The part that is getting me crazy is the "Base = Aggr". Up what I know the Aggr function returns a table, in the example above a table with all the maximum values of "Base" in "Contra", but if I remove the "Sum" and leave the measure like 

Base = Aggr(NoDistinct Max(Base), Contra)

It shows minus the number of maximum values that are equal per "Contra" dimension...

For more information, it comes from a solved post of mine: post 

Need clarification please!!

Thanks.

1 Solution

Accepted Solutions
MayilVahanan

Hi 

Its short form of below

Sum( If(Base = Aggr(NoDistinct Max(Base), Contra), 1, 0))

Ur dimension is Contra

So, its check the base = max(base) for that contra, if its yes, gives 1 else 0. 

---------------

Base = Aggr(NoDistinct Max(Base), Contra)

It shows minus the number of maximum values that are equal per "Contra" dimension...

Yes, its gives minus, that the reason, "minus" is added before sum() & gives the correct result

-Sum( Base = Aggr(NoDistinct Max(Base), Contra))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

4 Replies
MayilVahanan

Hi 

Its short form of below

Sum( If(Base = Aggr(NoDistinct Max(Base), Contra), 1, 0))

Ur dimension is Contra

So, its check the base = max(base) for that contra, if its yes, gives 1 else 0. 

---------------

Base = Aggr(NoDistinct Max(Base), Contra)

It shows minus the number of maximum values that are equal per "Contra" dimension...

Yes, its gives minus, that the reason, "minus" is added before sum() & gives the correct result

-Sum( Base = Aggr(NoDistinct Max(Base), Contra))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Morgoz
Contributor III
Contributor III
Author

Thank you Mayil,

now just tell me please, why does it returns "minus"? From your response, the formula is an abreviation of 

Sum( If(Base = Aggr(NoDistinct Max(Base), Contra), 1, 0))

And I don't see any minus in that formula... Base is always a positive number. Wouldn't it be

Sum( If(Base = Aggr(NoDistinct Max(Base), Contra), -1, 0)) ? 

But in any case why with minus?

Thank you!

anthonyj
Creator III
Creator III

Hi,

The calculation is implicitly summing the TRUE and FALSE results from the "Base = Max(Base)" calculation. Qlik calculates TRUE as -1 and FALSE as 0. This is why you end up with a negative number. To get around this you can wrap your calculation in the ABS( ) function or just multiply by -1.

Morgoz
Contributor III
Contributor III
Author

Great!

Thank you Anthony, now everything is clear.

By your response I think that the equivalent formula would be 

Sum( If(Base = Aggr(NoDistinct Max(Base), Contra), -1, 0)) 

But in any case I'll accpet Mayil's answer as correct.

Thank you again to both!