Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
i'm trying to create a chart that shows to how many stores each product is sold.
X axis should show "Time" dimension (days / weeks / months) and Y axis should show two expressions:
- Total number of stores to which each product has been sold at least once in a period - for that I'm using function "count(distinct(StoreID))" which works ok
- What % of the total store base that product was sold to. I was trying with the function below but it doesn't seem to work. Any suggestions?
count(distinct(StoreID))
/
count( total distinct (<Time> StoreID))
Many thanks
Captain,
I think we've been trying to solve different issues... In our responses, we tried to show you how to calculate the share of the TOTAL, i.e. disregard the dimension value in the denominator.
What you are trying to do is to calculate the percentage of the Store count by product, compared to all the stores in general. So, in addition to disregarding the Dimension values, you want to disregard the selection of the Product. The corresponding formula would be:
count(distinct StoreID)
/
count({<Product = >} Distinct Total <[$(=GetCurrentField(TIME))]> StoreID)
This Set Analysis condition will cause the expression to disregard any selections made in the field Product. If you need to disregard any other selections, add them into the list of Modifiers, separated by coma,
Site comment to you and Manish:
DISTINCT is not a function, but rather a qualifier within an aggregation function. Therefore, it doesn't require a set of parenthesis after it. So, instead of :
count(distinct(StoreID))
it's enough to write:
count(distinct StoreID)
The extra set of parenthesis doesn't break the formula but makes it more cluttered and less readable.
cheers,
Oleg Troyansky
www.masterssummit.com
time is your cyclic group?
if yes, use like below...
count(distinct(StoreID))
/
count( total distinct (<$(=GetCurrentField(TIME)> StoreID))
count(distinct(StoreID))
/
count(distinct total<TIME> StoreID)
This one gives always 100% result
Yes its a cyclic group but doesn't seem to work..
Have you tried below?
count(distinct(StoreID))
/
count(Distinct Total (<$(=GetCurrentField(TIME)> StoreID))
yes, also no result it just doesn't show anything. Also fields after $ sign are grey. Should they?
The correct syntax is:
count(distinct StoreID)
/
count(Distinct Total <[$(=GetCurrentField(TIME))]> StoreID)
In order to troubleshoot your expression, turn your chart into a Straight Table (or a Pivot Table) and leave the expression Label empty. You will be able to see exactly how QlikView renders your expression formula.
Oleg Troyansky
Come and learn advanced QlikView techniques from the best:
www.masterssummit.com
Oleg,
the formula you provided indeed has no errors. However - still no results - no data is being displayed. Perhaps there is a different formula to get the same result?
thanks
Regards
CaptainP
Oleg,
I have another strange problem - perhaps its a bug that results in not showing the formula you provided.
On my bar chart I have a formula count(distinct(StoreID))
Surpirisingly each product that i click on has different bar colours - this didn't happen before in case of other charts with similar structure
Any ideas on that?
Regards
CaptainP