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: 
Not applicable

Problem to count number of corporations

Hi everyone,

I'm working with Qlikview to count the number of corporations which operates with my company.

Each operation, can have more than one company.

An example:

     Nº of Operation     Date               Company

          2                    22/07               Company 1

          2                    22/07               Company 2

          3                    22/07               Company 1

          4                    23/07               Company 3

If I select the date = 22/07, and do a expression with count(Distinct (Company)), I receive the value =  2. This happens because the Qlikview counts only 2 companies, independent of the operations. But, I want the value = 3, because I have 2 companies in operation 2, and 1 in operation 3. The "Company 1" appeared in operation 2 and 3, but I want to count that company 2 times, not 1 like with count(distinct...).

Any solutions for this? With a expression like "distinct"? Or with a "If"? Or something else?

Thanks!

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try: =sum(aggr(count(distinct Company),[Nº of Operation])). See attached example.


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

Simply count(Company) will count the companies without removing duplicates.


talk is cheap, supply exceeds demand
Not applicable
Author

Yes, but the real situation is this: I have many fields:

     Operation -> Titles -> Date -> Company

An example:

Nº of Operation     Title     Date               Company

          2               54       22/07               Company 1

          2               55       22/07               Company 2

          2               56       22/07               Company 2

          3               57       22/07               Company 1

          4               58       23/07               Company 3

See? In operation 2, I have 3 titles and 2 companies. If I select operation 2, I want the value = 2, for number of the companies. But If i select operations 2 and 3, I want to see 3.

My boss is asking me for this: If I have the same company appeared 2 times in the same operation, the company have to be count only 1 time. But If the company appeared 2 times, but in different operations, the company have to be count 2 times.

Understand?

Gysbert_Wassenaar

Try: =sum(aggr(count(distinct Company),[Nº of Operation])). See attached example.


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks man! Works perfectly!