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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
vstone
Contributor
Contributor

Creating a calculated field for grouped attributes

For the given table (attached):

Capture.PNG

TLDR: I'm trying to get the average percent compliant grouped by br_name and br_category.

So doing a pivot table works, but I won't be able to get a bar chart off of a pivot table which is why I'm trying to create the percent_compliant field using a set expression

BR_185550A passes three times, it's average compliance is 100%. It's category is Syntax, so the Syntax category compliance average is at 100% thus far. BR_101082 fails once, so it's average compliance is 0%, and it's category is Syntax so the overall Syntax category compliance drops down to 50%. This is the number I want, 50% for the Syntax category. And just like that for the rest of the categories. The percent_compliant and percent_compliant_aggr are master items i created to try and get this average percent compliant field by br_category and br_name. I'm not quite there yet.
 
For reference this is the set analysis expression for the percent_compliant_aggr field:
Aggr(Count(total<br_name>{<compliance_check={'Pass'}>}br_name)/count(total<br_name>{<compliance_check={'Pass','Fail'}>}br_name),br_name)
 
The aggr function is the intermediate step. it properly aggregates the average percent compliance by br_name. next step is to average the result of that function by br_category, which i'm not sure how to do with set expressions
Labels (4)
2 Replies
Steven_Haught
Creator III
Creator III

Did you try adding the following in your total expressions?

, br_category

 Here is a really good write up on total with aggr. 

https://community.qlik.com/t5/Qlik-Design-Blog/Totals-in-Charts/ba-p/1464797

Steven_Haught
Creator III
Creator III

You may even be able to go a little simpler. Give this a try? 

Aggr(
Count({<compliance_check={'Pass'}>}br_name)
/
count(total<br_name, br_category> br_name)
,br_name)