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

Aggr function not working in P() element function

Hi,

I have an issue while using P() element function with Aggr combination in QlikView

Here is my expression:

concat(aggr(concat({<[Hold Code]=P({<[Hold Code Priority]={"$(=aggr(max([Hold Code Priority]),[Claim Number]))}>})>}[Hold Code]),[Claim Number]))

I am trying to find the possible values for [Hold Code] using the [Hold Code Priority] field. And in order to populate the values for [Hold Code Priority] , I am taking the it's maximum value grouped by [Claim Number]. I am trying to concat those Hold codes.

Since I am using this in a chart with [Claim Number] as dimension, I did an aggr over [Claim Number] field and finally adding an aggregation function outer concat to get the output.

This expression is working fine in a text object when I select a Claim Number. But when I copy this into a chart expression is not working.

Any help on this would be appreciated.

Thanks,

Srikanth

6 Replies
Anonymous
Not applicable
Author

In continuation to my above question, when I actually pass in static values in the set for P() function like {6,7,8}, I still get the output in the chart.

I guess my understanding of P() function with aggr combination is not correct.

Thanks,

Srikanth

tresesco
MVP
MVP

'Set analysis gets evaluated once for a chart and not row-wise'. I have seen, knowing this people try using aggr() to get over the problem. Unfortunately, let me tell you that - here too, you are not going to get set analysis executing row-wise of a chart. It's a wrong perception. To achieve, something similar, you might have to create additional field in the script; usually a composite field.

If you could come up with a sample qvw and explain the expected output out of it, we might give a try helping you out. And yes, at the first look at your expression (without realizing much about your requirement, ), expression seems to be not very optimized.

Anonymous
Not applicable
Author

Thanks Tresesco!! Let me come up with some sample data for my issue and the output I am expecting.

Yes, in order to make it work, I complicated my expression using aggr() and outside concat() function.


I will provide a sample example soon.


Thanks,

Srikanth

Anonymous
Not applicable
Author

Hi Tresesco,

Here is some sample I came up with.


CN: Claim Number  CLN: Claim Line Number  HC: Hold Code  HCP: Hold Code Priority


Data:                                                                                            

CNCLN  HC       HCP
12345123451     A9
12345123452J8
12345123453R9
12345123454F7
23456234561M5
23456234562D4
23456234563D4
23456234564F6
23456234565Q2
34567345671J8
34567345672P8
34567345673F7
45678456781B5
45678456782B5
45678456783V3
45678456784H2

Output: 

CNHC
12345A,R
23456F
34567J,P
45678B

I am trying to calculate the Maximum HCP for each CN and concat all HC's for that CN based on highest HCP.


CN 12345 has four CLN's ie., 123451,123452,123453,123454.


Maximum HCP is 9. So concat HC's A and R. 

Hopefully I am clear with my sample example.

Thanks,

Srikanth

swuehl
MVP
MVP

You can get your result using for example

CN Concat(DISTINCt Aggr( If(HCP = Max(Total<CN> HCP),HC), CN, CLN),', ')
A, B, F, J, P, R
12345A, R
23456F
34567J, P
45678B

You could also flag your CLN with the highest priority in the script, adding after your Data table load

LEFT JOIN (Data)

LOAD CN, Max(HCP) as HCP, 1 as MaxHCP

Resident Data

GROUP BY CN;

and then you can use set analysis to filter your HC per CN:

CN Concat({<MaxHCP = {1}>} DISTINCT HC,', ')
A, B, F, J, P, R
12345A, R
23456F
34567J, P
45678B
Anonymous
Not applicable
Author

Hi Stefan,

Thank you so much!!

It worked.

Srikanth