Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
tracycrown
Creator III
Creator III

Aggr function not working

Dear all

I managed to compute the average score 53.0 for 5 batches but failed to show the result, please advise urgently.

Thank you so much

Tracy

1 Solution

Accepted Solutions
sunny_talwar

Here you go, try these expressions:

With Type:

If(Dimensionality() <= 1, Aggr(If(Avg(TOTAL Score) >= [Lower] and avg(TOTAL Score)<= [Upper], Result), Batch, Type, Result), Aggr(If(avg(Score)>= [Lower] and avg(Score)<= [Upper], Result), Batch, Type, Result))

With Type and Item

If(Dimensionality() <= 2, Aggr(If(avg(TOTAL Score)>= [Lower] and avg(TOTAL Score)<= [Upper], Result), Batch, Type, Item, Result), Aggr(If(avg(Score)>= [Lower] and avg(Score)<= [Upper], Result), Batch, Type, Item, Result))

View solution in original post

14 Replies
sunny_talwar

What are you expecting to see?

engishfaque
Specialist III
Specialist III

Dear Tracy,

Kindly find attached App, I hope you are looking for that one.

For quick output, screenshot is given below:

Output.png

Kind regards,

Ishfaque Ahmed

sunny_talwar

Ishfaque‌ - I think using MinString is not going to work. For instance if I select Batch 10004 and 1005, I should be seeing Bad, but because minstring of Bad and Average is Average, I still see Average

Capture.PNG

tracycrown
Creator III
Creator III
Author

Dear Ishfaque Ahmed

Kindly advise what is the function (or purpose) of MinString in the script.

Thank you very much Tracy

sunny_talwar

MinString works similar to Min function, but the unique thing is that it works on Text field. So since Average begins with an A, it is smaller than Bad which begins with B. Does that make sense?

tracycrown
Creator III
Creator III
Author

Dear Sunny

So what is your answer for this, change MinString to AvgString ?.

Thank you

Tracy

sunny_talwar

I don't even think AvgString exists, but this is not the right approach. Do you see the screenshot above? Is Average the right result. I don't think so, but you would know better. We def. need to look for another approach here.

sunny_talwar

Tract try this expression:

If(Dimensionality() = 0, Aggr(If(avg(TOTAL Score)>= [Lower] and avg(TOTAL Score)<= [Upper], Result), Batch,Result), Aggr(If(avg(Score)>= [Lower] and avg(Score)<= [Upper], Result), Batch,Result))

With no selections

Capture.PNG

With Selection of Batch 10004 and 10005

Capture.PNG

tracycrown
Creator III
Creator III
Author

Dear Sunny

Thank you so much for your help, your advice works well in a simple dataset.

However, it does not work if more fields (Type, Item) are added, please help. Sorry to say that Qlikview do not allow me to attach Test-2.xlsx.

   

BatchTypeItemScore
10001AA10170
10001AA10280
10002BB10167
10002AA10227
10003CC10156
10003BB10135
10004DD10142
10004EE10121
10005AA10230
10005BB10219

Thank you

Tracy