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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
nevilledhamsiri
Specialist
Specialist

Average calculation at the script level

Dear All!

Appreciate, if I'm helped with, to calculate average at the script level so that I need to be able to write a nested if statement to prepare a class  like (>30000, 20000-30000,10000-20000 ) etc ,based on the average computed at the script level. Since the value given is not the average the class function to be based on the average. Also, the average here should be the half of the value of each employee.

 

Thanks in advance

 

Neville

14 Replies
nevilledhamsiri
Specialist
Specialist
Author

Dear Kush

Your script structure was applied & it is almost there but following script error coming while data is loaded. Please see what may causes this error?

Thanks for the reply

Invalid expression
LEFT JOIN (MAIN)

LOAD
BR_CODE,ME_CODE,

SUM(AMOUNT)/Age_in_month AS AVG_COMM

RESIDENT MAIN

GROUP BY ME_CODE,BR_CODE

nevilledhamsiri
Specialist
Specialist
Author

 

Hi Kush,

Following error comes when the data are loaded. Could you please refer this & see what the error is? I tried to locate but no idea where it is connected with. 90% must be ok  as the age calculation is happening as expected.

 

Neville

 

Invalid expression
LEFT JOIN (MAIN)

LOAD
BR_CODE,ME_CODE,

SUM(AMOUNT)/Age_in_month AS AVG_COMM

RESIDENT MAIN

GROUP BY ME_CODE,BR_CODE

Kushal_Chawda

change below

LEFT JOIN (MAIN)

LOAD
BR_CODE,ME_CODE,

SUM(AMOUNT)/max(Age_in_month) AS AVG_COMM

RESIDENT MAIN

GROUP BY ME_CODE,BR_CODE

nevilledhamsiri
Specialist
Specialist
Author

Yet to encounter the same script error what I have noted earlier though the adjustment was done as you proposed.

Kushal_Chawda

can you share script?