Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

manojkumargowda
New Contributor III

Percentage calculation with filter condition

Hi All,

I need to calculate percentage of number employees in HR department (wrt to all employees) and % of sum of salary in HR dept (wrt to all employees). So I'm writing an expression like below, but it is not giving correct result.

(count({<Dept={'HR'}>}Id)/count({<Dept={'HR'}>}Total(Id)))*100

(Sum({<Dept={'HR'}>}[salary])/Sum({<Dept={'HR'}>}Total([salary])))*100

1 Solution

Accepted Solutions
Khan_Mohammed
Honored Contributor II

Re: Percentage calculation with filter condition

(count({<Dept={'HR'}>}Id)/count({<Dept={'HR'}>}Total(Id)))*100

(Sum({<Dept={'HR'}>}[salary])/Sum({<Dept={'HR'}>}Total([salary])))*100

You are using Dept=HR filter in both the expressions...

I think you said you want it by all the employees, not just the HR Dept. Maybe you do not need Total here

Just a basic expression might work?

(count({<Dept={'HR'}>}Id)/count(Id))*100

(Sum({<Dept={'HR'}>}[salary])/Sum ([salary]))*100

Not sure if above expression I gave is correct or not..

2 Replies
Khan_Mohammed
Honored Contributor II

Re: Percentage calculation with filter condition

(count({<Dept={'HR'}>}Id)/count({<Dept={'HR'}>}Total(Id)))*100

(Sum({<Dept={'HR'}>}[salary])/Sum({<Dept={'HR'}>}Total([salary])))*100

You are using Dept=HR filter in both the expressions...

I think you said you want it by all the employees, not just the HR Dept. Maybe you do not need Total here

Just a basic expression might work?

(count({<Dept={'HR'}>}Id)/count(Id))*100

(Sum({<Dept={'HR'}>}[salary])/Sum ([salary]))*100

Not sure if above expression I gave is correct or not..

manojkumargowda
New Contributor III

Re: Percentage calculation with filter condition

Thanks Shahbaz, second one worked for me..

(count({<Dept={'HR'}>}Id)/count(Id))*100

(Sum({<Dept={'HR'}>}[salary])/Sum ([salary]))*100

Community Browser