Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.
Try this
Count({1<Product = P(Product), Country = P(Country)>} DISTINCT User)
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.