Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
DMG
Contributor III
Contributor III

Counting as a percentage of total

I have training data for users, in the following format

course title, user_id

When i create a table, i can easily show

Course Title, Total of users assigned to that course

But i'd also like to add a third column (% of total unique users assigned to that course)

So if i had 50 users, 10 on that course the data would read

Course A, 10, 20%

I'm trying to work out how to do this because qlik restricts the row data down to "course a" so not sure how to count outside that restriction to get the % ?

 

Thanks 

 

9 Replies
Taoufiq_Zarra

@DMG  can you share a sample data and the expected output ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Ksrinivasan
Specialist
Specialist

Hi,

 

=count(course)/50*100

DMG
Contributor III
Contributor III
Author

Something like this

User, Course,
A, First Aid
B, First Aid
C, First Aid
A, Security
D, Security

So the expected response would be

Course, number of assigned users, percentage that number of assigned users is off the total users

First Aid, 3, 75%
Security, 2, 50%

As they are four users (A-D) and two courses

The course numbers and users can change, the idea is to be able to have a table that shows the course name, number of assigned users, and the percentage that number is of the total number of users (in this case 4).

Because qlik restricts the row data down as soon as the first column is Course, i'm not sure how to be able to access the total user value of 4 so i can work out the percentage of total users.

 

DMG
Contributor III
Contributor III
Author

Thanks but that wont work as the number of users and courses can vary dynamically.

Ksrinivasan
Specialist
Specialist

Hi,

Aggr(Count(course), course/Distinct (user)*100

 

Ksrinivasan
Specialist
Specialist

Hi,

(Aggr(Count(course),course)/distinct (user))*100

stevejoyce
Specialist II
Specialist II

Your denominator should use TOTAL.  You don't need aggr.

Count(user_id) / Count(Total user_id).

 

FYI - if you need to set your aggregation to different levels you can do Total <field1, field2, fieldn>  but in this case you only need the global total.

Ksrinivasan
Specialist
Specialist

Hi,

Aggr(count(course),cou cou)/count(total distinct (user))*100

It gives requester result. Verified ok

stevejoyce
Specialist II
Specialist II

ok good, but you shouldn't need the outer aggr().