histogram with bucketting (frequency) As an exampl...
# gd-beginners
r
histogram with bucketting (frequency) As an example of what I’m trying to do: • the dataset is a list of records
datetime, temperature_f
• I have a metric
temperature_c
that does the conversion from F to C (my point here is I can’t use directly the value of the DB) • I want an histogram will display the count of records where
temperature_c
falls in a specific bucket (0-20, 21-30,31-40, etc..) I tried a barchart but the X axis has to be an attribute but here obviously the bucket ‘name’ is based on a metric that is calculated. Any suggestion on how to go about this?
t
Hello @Romain Eude, do you know if you are using GoodData platform or GoodData Cloud?
r
GD hosted cloud version
t
In GD Cloud bucketing is not available out of the box, but I can recommend few approaches to deal with the situation. 1. Create a metric for each of your buckets and then create a column chart with all these metrics. I used this trick when creating price distribution of the Star Wars sets. See the attached image below. 2. Use our SQL datasets feature to create the buckets using SQL. Using SQL datasets you don’t need to change anything in your DB. 3. Prepare the buckets in your DB and connect the appropriate VIEW/TABLE to the GD LDM.
p
🎉 New note created.
r
Thanks @Tomas Muchka. The challenge I have here is that in my use case is the metric to bucket is the result of some calculation involving aggregation. IRL, it is the return rate of a product sold across multiple orders. So I want to look at the distribution of the return rate across product prices. the order lines are the fact. So if I understood correctly, solution 2 won’t work because I will loose any filter the rest of my existing ldm features. • for sol 1, can you share the code to the metric(s)? • for sol 3, it implies I need to add an attribute (string) to my fact table (bucket_id) and then do a barchart where I count the orderlines, group by bucket id. correct? There used to be ‘computed attributes’ in an old version of the docs but I guess this doesn’t exist anymore? •
t
The metrics look like this. I believe there are other possibilities such as using CASE statement instead of WHERE
As for computed attributes, you are right. This functionality is currently not available and you would need to mimic it using ETL/SQL tools