Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
zagzebski
Creator
Creator

Aggr Count Distinct

I need to count distinct clients who had a combined 100 in sales. Looking for some help on expressions:\

DATA:
DeptClientSales
A150Doesn't Meet Criteria
A140Doesn't Meet Criteria
A275Meets Criteria
A275Meets Criteria
A3150Meets Criteria
B1100Meets Criteria
B1100Meets Criteria
B450Doesn't Meet Criteria
C1150Meets Criteria
C5100Meets Criteria
C5100Meets Criteria
OBJECT:
DeptTotal Sales of Clients who had at least 100 in salesCount Distinct Clients with Total Sales of 100 or more
A3002
B2001
C3501
13 Replies
swuehl
MVP
MVP

Where do the two fields (?) ProductionBeginDate and ProductionEndDate come from? Or are they variables?

In general, you can use an advanced search on your ProdGLDate in your set analysis field modifier, something like (assuming variables):

=sum(

{<^CustDept = {"=[Commission Dept CummPerc]<=$(vRetensionPct)"},

               ProdGLDate = {">=$(ProductionBeginDate)<=$(ProductionEndDate)"} >}

Commission)

zagzebski
Creator
Creator
Author

These are not variables - they are part of the load process. I had an example of the expression with variables but can't figure out how to adjust it if these are just regular fields

swuehl
MVP
MVP

If these fields only have 1 distinct value each, you can just replace the variable by the field name:

=sum(

{<^CustDept = {"=[Commission Dept CummPerc]<=$(vRetensionPct)"},

               ProdGLDate = {">=ProductionBeginDate<=ProductionEndDate"} >}

Commission)


If you have several values per field, you need to decide which value to pick, maybe the maximum / minimum?


=sum(

{<^CustDept = {"=[Commission Dept CummPerc]<=$(vRetensionPct)"},

               ProdGLDate = {">=$(=min(ProductionBeginDate))<=$(=max(ProductionEndDate))"} >}

Commission)

zagzebski
Creator
Creator
Author

Thanks - my problem is I need this variable in a prior load so I was not sure how to handle that. I used these two fields (ProductionBeginDate and ProductionEndDate) as variables in that load then just added them to a table and brought them through to the final model.

Question: what is the best way to get these two variables in a prior QVW and use them in the final model (QVW) too.  I am trying to avoind putting them ni twice (two different files).