Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
jcampbell474
Creator III
Creator III

Possible Set Analysis Question

I am using QV11 and having trouble with an expression.

My issue is:  I have a table loaded with Dept, subDept, product_code, empid, and emp_name.  I need to get a headcount of each employee in the main department.  When I create the chart (straight table), I create these dimensions and use count(distinct(empid)), it appears that QV is counting the distinct empid within each subdept and product_code - effecitvely counting duplicate empids.  The output has to include the subdept, product_code, and headcount fields. 

My output right now is inflated due to employees listed multiple times (they can be in multiple subdepts)…I just need to count the distinct number of empid’s w/in the main department.  I need the expression to ignore subdept and product_code.  I feel like some type of set analysis applies here, but not sure what to do.  Does anyone have any advice/suggestions?

Thank you in advance.

8 Replies
awhitfield
Partner - Champion
Partner - Champion

Hi Jason,

can you post some example data for this, say in excel?

Cheers

Andy

jcampbell474
Creator III
Creator III
Author

I can't find a way to attach a file, so here is a sample table:

Dept IDProduct CodeempidEMPNAME
500900500180001234567xxx, yyyy
500900500180001234568xx,yyy
500900546680001234569x, y
425464433335002345678xxxx, xxxx
425492422435002345678xxxx,xxxx
425464422235003456789xxx,xxx
425464433336503456789xxx,xxx
In QV, this gives me a headcount of 7.
It's actually 5 employees, by counting distinct empids.
Not applicable

Hi Jason,

you said "The output has to include the subdept, product_code, and headcount fields"

In this case, the answer cannot be different: if there's more than a combination of empid + Product Code + Dept ID you'll see all of them.

If on that table you only want to see once each empid you must avoid other dimensions.

Cheers

Luca

luciancotea
Specialist
Specialist

... and the definition of main department is...?

sunny_talwar

Try this:

=Count(DISTINCT empid)

This will only count the distinct occurrences of each Employee id.

HTH

Best,

Sunny

Not applicable

What Luca mentioned is correct.

You can do it with one dimension but not multiple dimensions.

Regards

Koushik Vutha

jcampbell474
Creator III
Creator III
Author

I was thinking set analysis could manipulate the expression independent of the dimensions.  At any rate, a big thanks to all who replied.  I figured it out.  The datasource contained additional departments that was defined before.  Their numerical range happened to fall w/in a range of the departments I was testing.  So, it's all good now.  Thanks again.

awhitfield
Partner - Champion
Partner - Champion

PS - if you want to attached something to a post, then click on 'Used advanced Editor' and away you go!

Andy