Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
manojkumargowda
Creator
Creator

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
MK9885
Master II
Master II

(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..

View solution in original post

3 Replies
MK9885
Master II
Master II

(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
Creator
Creator
Author

Thanks Shahbaz, second one worked for me..

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

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

Girijesh
Contributor
Contributor

Dear Manoj,

Just wanted to check, id is a column which is primary key for Emp table, right?

In summary, Table structure for this is Id and Deparment, am i right in my understanding?