Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count of rows using aggr

Hi,

I have a straight table as below.

Retail(Managers)KPI1KPI2KPI1/KPI2Grade
Anu1002000.5B
Manka3004300.69A
Tunai1001500.66A
Ruku2004500.44C
Payel1503000.5B

The First column is a cyclic group named Retail. The cyclic group is defined as follows:

Region---->Zone--->Managers--->Field Employee---->Store.


Store is the lowest level in the hierarchy of cyclic group. The logic for the above table is simple. If KPI1/KPI2 is equal to 0.5 then Grade= B, if Greater then A else C.


I have pre-selected the Zone named as US East in the list box.

I need to display a table as below


Retail(Zone)Number of ANumber of BNumber of C
US East221


So,all the above Managers belonged to the Zone named as US East. When I cycle up in the Cyclic group to show Zone, I should see the count of Managers under that Zone having A, B or C. Similarly for other Zones as well.


I have used this expression with no luck:


If

(

getcurrentfield([Retail])='Zone' ,

count

  (

  aggr

  (

  If

  (KPI1/KPI2)=-0.5,1),MANAGER_NAME

  )

  ) ,

If

(

getcurrentfield([Retail])='Managers' ,

count

  (

  aggr

  (

  If

  (KPI1/KPI2)=-0.5,1),FIELD_EMPLOYEE_NAME

  )

  ))


Appreciate your help to determine the issue and help with a working solution to achieve the result.


Thanks,

Tutan

6 Replies
Nicole-Smith

Please do not post the same question multiple times.  The original thread is being replied to here: Expression help

Not applicable
Author

Hey Tutan,

This is just a suggestion. Dunno if it will be applicable for your case.

Why don't you create a flag in the backend like Grade using the same logic you are using on the front end. Once you have the flag all you have to do is use an If condition and count the flag for those three expressions in the second table.

Please let me know if it was helpful.

Thanks,

AJ

Not applicable
Author

Hi AJ,

I like the idea. But, I want to know where is the issue here. Just wanted to save some time in writing a new piece of code. I have a feeling that selection in the cyclic group is a problem here. I have used a similar kind of an expression by omitting the cyclic group selection part, just for counting number of store and it just worked fine across hierarchies.Just curious to know where am I doing it incorrectly...

Regards,

Tutan

Not applicable
Author

Sorry Nicole, my apologies...

Nicole-Smith

No problem, Tutan.  Questions are easier to answer when having the entirety of the information, which someone would be missing had they not read the other thread.  It just makes it easier if everything is in one place

Not applicable
Author

The reason I suggested back end calculation is because the If condition on front end is resource intensive so it could have some impact on performance.

But if you wanna use it on Front end, please try this one:

=if(GetCurrentField([Retail])='Zone', count(if(aggr(((KPI1)/(KPI2)),Managers)>.5,1)))

I just moved If and aggr around and this is only for A. You can do the same for the remaining two.

I have attached a sample file. Also please note that the second table will work only when the Group is 'Zone'.

Thanks

AJ