Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
Gartner® Magic Quadrant™: 15 YEARS A LEADER - GET THE REPORT
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlikuser225
Contributor III
Contributor III

Help with Qlik Sense

Hello,

Can anyone please help me with below. I have a data 

Country       Product        User
USA            Electronics    123
USA            Electronics    123
USA           Electronics    123
USA           TV                 123
USA           TV                 134
USA           Laptop           156
CANADA    Electronics     456
CANADA     Electronics     567
CANADA      Electronics    765
CANADA     TV                  456
CANADA     TV                  567
CANADA     Watch            765

When USA is selected

Product      Count of Users
Electronics         3
TV                      2
Laptop                 1
Ipad                     0
Smart Phone       0
Watch                    0

When CANADA is selected

Product         Count of Users
Electronics              0
TV                           2
Laptop                     0
Ipad                         0
Smart Phone            0
Watch                       1

The Product column should always show all the Products regardless on selection and should display 0 if there are no products for the given selection.

Thanks in Advance

 

 

 

Labels (4)
1 Solution

Accepted Solutions
Mark_Miron
Contributor II
Contributor II

I think this may get you what you want.

Using this as the sample dataset:

table:
LOAD *
INLINE [
Country|Product|User
USA|Electronics|123
USA|Electronics|123
USA|Electronics|123
USA|TV|123
USA|TV|134
USA|Laptop|156
CANADA|Electronics|456
CANADA|Electronics|567
CANADA|Electronics|765
CANADA|TV|456
CANADA|TV|567
CANADA|Watch|765
] (Delimiter is '|');

Products:
LOAD *
INLINE [
Product
Electronics
TV
Laptop
Ipad
Smart Phone
Watch
];

Then in the pivot table you have

dimension = 'Product'

measure = (COUNT({1}DISTINCT Product)-1) + COUNT({<User={"=COUNT(Country)>0"}>} Product)

I am super curious to know if this works out for you.

View solution in original post

3 Replies
Mark_Miron
Contributor II
Contributor II

I think this may get you what you want.

Using this as the sample dataset:

table:
LOAD *
INLINE [
Country|Product|User
USA|Electronics|123
USA|Electronics|123
USA|Electronics|123
USA|TV|123
USA|TV|134
USA|Laptop|156
CANADA|Electronics|456
CANADA|Electronics|567
CANADA|Electronics|765
CANADA|TV|456
CANADA|TV|567
CANADA|Watch|765
] (Delimiter is '|');

Products:
LOAD *
INLINE [
Product
Electronics
TV
Laptop
Ipad
Smart Phone
Watch
];

Then in the pivot table you have

dimension = 'Product'

measure = (COUNT({1}DISTINCT Product)-1) + COUNT({<User={"=COUNT(Country)>0"}>} Product)

I am super curious to know if this works out for you.

Chanty4u
MVP
MVP

Try this 

Count({1<Product = P(Product), Country = P(Country)>} DISTINCT User)

 

Mark_Miron
Contributor II
Contributor II

it seems that doesn't work as expected but i updated it to

Count({1<Product = P(Product), Country = P(Country)>} Product)

That got the expected result. You still need to load a separate Products table for reference.