Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
vinieme12
Champion III
Champion III

Average by Group for Max QTR

Hi Guys,

Need your help with an expression.

Need to Average Rank for the latest QTR only

So Group1=(9+4+5)/3    <<<3 being latest for Group1

and Group2=(7+5)/2    <<<<4 being latest for Group2

   

GroupRecNameQTRRANK
11111AAAAA19
11111AAAAA39
12222BBBBBBBBB28
12222BBBBBBBBB34
13333ccccccccccccccc35
13333ccccccccccccccc26
25555yyyyyyyy19
25555yyyyyyyy47
26666iiiiiiiiiii16
26666iiiiiiiiiii24
26666iiiiiiiiiii34
27777mmmmmmmmmm45
Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
1 Solution

Accepted Solutions
sunny_talwar

May be this (but not sure if this is any better than the if statement approach

Sum({<Key = {"=QTR = Aggr(Max(TOTAL <Group> QTR), Key, Group)"}>} RANK)/Count({<Key = {"=QTR = Aggr(Max(TOTAL <Group> QTR), Key, Group)"}>} RANK)

Other approach

Sum(Aggr(If(QTR = Max(TOTAL <Group> QTR), RANK), Group, Name, QTR))/Count(Aggr(If(QTR = Max(TOTAL <Group> QTR), RANK), Group, Name, QTR))

View solution in original post

11 Replies
sunny_talwar

May be this:

Sum(Aggr(If(QTR = Max(TOTAL <Group> QTR), RANK), Group, Name, QTR))/Max(QTR)

vinieme12
Champion III
Champion III
Author

Thanks for your prompt response stalwar1

first part works, but need to divide it by the number of instances being totaled instead of Max(QTR)

Group1=(9+4+5)/3    =  6

and Group2=(7+5)/2 = 6

also is there a way to do this in Set?

Thanks

Vineeth

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
sunny_talwar

May be this (but not sure if this is any better than the if statement approach

Sum({<Key = {"=QTR = Aggr(Max(TOTAL <Group> QTR), Key, Group)"}>} RANK)/Count({<Key = {"=QTR = Aggr(Max(TOTAL <Group> QTR), Key, Group)"}>} RANK)

Other approach

Sum(Aggr(If(QTR = Max(TOTAL <Group> QTR), RANK), Group, Name, QTR))/Count(Aggr(If(QTR = Max(TOTAL <Group> QTR), RANK), Group, Name, QTR))

vinieme12
Champion III
Champion III
Author

Fab , thanks a lot stalwar1

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
sunny_talwar

No problem, I am glad I was able to help bro

jyothish8807
Master II
Master II

Hi Sunny,

Can you please help me to understand the below expression ?

Sum({<Key = {"=QTR = Aggr(Max(TOTAL <Group> QTR), Key, Group)"}>} RANK)/Count({<Key = {"=QTR = Aggr(Max(TOTAL <Group> QTR), Key, Group)"}>} RANK)

How "QTR = Aggr(Max(TOTAL <Group> QTR), Key, Group)" is giving the relevant Key valu?

Thanks in advance


Br,

KC

Best Regards,
KC
sunny_talwar

Create a straight table with Key as dimension and three expressions

1) QTR

2) Aggr(Max(TOTAL <Group> QTR), Key, Group)

3) RANK

Wherever 1st and 2nd expressions have same value, RANK will be summed.

jyothish8807
Master II
Master II

So in the above expression "Key" will automatically identify the all the Key values where the below condition is fulfilled ?

"QTR = Aggr(Max(TOTAL <Group> QTR), Key, Group)".

Best Regards,
KC
sunny_talwar

Exactly