Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Group by within an Expression

Ok, there has to be an easy way to do this....

I have a data set containing person name, company name, and company revenue.  Since there are multiple people per company, the company revenue figures are repeated several times.  I need a report showing number of people, number of companies, and total revenue.  How do I set this up in a pivot table to avoid the double counting?

Thanks.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Something like

=sum( aggr(only(Revenue), Company))

should do then.

View solution in original post

6 Replies
onetwothree123
Partner - Contributor III
Partner - Contributor III

draab,

Try using DISTINCT in your expression

Not applicable
Author

I know DISTINCT would work with the company names -- i.e., =count (distinct Company_Name)

But it's perfectly possible that there will be several companies reporting the same revenue, which I should think would cause problems.  Can you give an example of code that would work for the Revenue figures?

Thanks.

Not applicable
Author

could you upload an example of your data?

Not applicable
Author

Hi Draab,

If you do not have a revenue figure per person then if you include person as a dimension you will get the revenue repeated across that dimension.

Prehaps use comapny as the dimension, and then do a distinct count of people and a sum of revenue as expressions.

Thanks,

James

swuehl
MVP
MVP

Something like

=sum( aggr(only(Revenue), Company))

should do then.

Not applicable
Author

That did it.  Thanks much.  Never saw 'only' before, but I'm very rusty.