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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Rich5678
Contributor III
Contributor III

In Totals Row, show Avg() of Selected Rows

Hello,

I have a Table with Stud ID and Marks. 

I am using a Table chart to display data.

I want to turn "Totals" to "On" and use "Totals Function" as "Avg" for Marks column.

However, I want to take the Average of first 5 students Only and ignore the Zeroes of the last 3 students.

In other words, I want to see the Totals Row at the Bottom to show Average of (95,85,75,68 and 92)=83 and Not 51.875 which includes the 3 zeroes at end. 

Marks:
Load * inline [
Student|Marks
Stud1|95
Stud2|85
Stud3|75
Stud4|68
Stud5|92
Stud6|0
Stud7|0
Stud8|0
] (delimiter is '|');

Above is the loading script.

Many thanks

 

Labels (5)
2 Replies
G3S
Creator III
Creator III

Introduce 'Aver' as a student, but no marks in the load. 

then, in the straight table in the front end, 

if(Student='Aver',avg({$<Student-={'Aver'},Marks-={0}>}TOTAL Marks),Marks)

but this is a calculated field, not auto totals. you can turn off the totals. 

 

Rich5678
Contributor III
Contributor III
Author

Many thanks,

May I ask a couple of follow up questions..

1. Instead of introducing a new Student "Aver", can't I not substitute, if(not match (Student, 'Stud6', ''Stud7, 'Stud8') - If so, could you help with the notation for that formula?
2. Now, how do I place the calculated Average in the Row where Totals would show up

Thanks