Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I am working on a chart that present phone brand share. One rule is that only brands with more than 4 users will be presented in my chart. I have data for several months and want to enable default month selection when there is no selection made.
Here are my steps:
Problem: When I select month that is not the latest one, there isn't any dimension presenting in my chart.
My expression:
IF(GetSelectedCount(month_id) = 0,
IF(AGGR( COUNT(DISTINCT {1< month_id = {$(=max(month_id))} >} user), brand) > 4, brand),
IF(AGGR( COUNT(DISTINCT {1<month_id = P({$} month_id)>} user), brand) > 4, brand)
)
Is there anything incorrect in my expression or there is a better way to implement this?
Thanks in advance!
Another idea would be
=Aggr(If(Count(DISTINCT {1<month_id = $(=IF(GetSelectedCount(month_id) = 0,'{$(=Max(month_id))}','P({$} month_id)') >} user) > 4, brand), brand)
How about trying this as your calculated dimension:
Aggr(If(Count(DISTINCT {1<month_id = {$(=Max(month_id))}>} user) > 4, brand), brand)
When nothing is selected Max(month_id) will hopefully be the latest
When you make a selection in Month field, month_id will also filter and the Max(month_id) will change to whatever you have selected.
Now, I am not sure if you have several years in your application, because having multiple years can be problematic if your month_id is just from 1 to 12. Lets say that we are in May 2016 and the max month_id needs to be 5, but because we have Dec 2015 in the application, we might end up getting 12 as max_id (this is when nothing is selected). How do you plan on dealing with this?
Another thing to consider is, if you have multiple years, do you wish to see all years data for that particular month or just the most recent?
I think it would be easier if you can provide a sample with your expected output.
Best,
Sunny
I assume you are using this as calculated dimension and you want to have the ability to select more than 1 month_id.
Try maybe
IF(GetSelectedCount(month_id) = 0,
IF(AGGR(NODISTINCT COUNT(DISTINCT {1< month_id = {$(=max(month_id))} >} user), brand) > 4,brand),
IF(AGGR(NODISTINCT COUNT(DISTINCT {1<month_id = P({$} month_id)>} user), brand) > 4,brand)
)
Another idea would be
=Aggr(If(Count(DISTINCT {1<month_id = $(=IF(GetSelectedCount(month_id) = 0,'{$(=Max(month_id))}','P({$} month_id)') >} user) > 4, brand), brand)
Hey it worked! Thanks for the help.
Also one more question if you don't mind.
User Brand
A Apple
A Samsung
B Samsung
B HTC
C Blackberry
I have this chart displaying phone brand as dimension and brand share among users as measure.
When I make a brand selection, the chart will only present the selected brand, with share = 100%. (say i picked Samsung, it only presents Samsung). But I want to present Apple too because user A has both Apple and Samsung.
So the result i want is as followed:
Samsung 100%
Apple 50%
Before I was using the following expression in dimension and it worked. But now I have added default month selection and it doesn't do the trick anymore.
IF(AGGR(COUNT(DISTINCT {1<user= P({$} user)>} panelist_id), brand) > 4, brand)
Thanks again for the help.
Hi Sunny,
It works!
I have used month_id which will be incremental for this chart.
Thanks for your help.
This questions are not easy to answer without knowing the data (model), but I would try not limit the dimensions in the calculated dimension, but in the expression (or just try similar in your calculated dimension), using a set expression in all aggregations like
{<Brand = p({<User = p(), Brand= >} Brand) >}