-->

How to make a simple histogram (representing a dis

2020-07-08 07:32发布

问题:

Do you know if it's possible to make a simple histogram representing the frequency of all my values divided by ranges (0-5;5-10;10-15;15-20 ...) ?

Exemple:

回答1:

The easiest way would be to format your data into "bins." You could do something like this:

count(CASE WHEN Age > 0 AND Age <= 5 Then 1) AS bin1
count(CASE WHEN Age > 5 AND Age <= 10 Then 1) AS bin2
count(CASE WHEN Age > 10  AND Age <= 15 Then 1) AS bin3
count(CASE WHEN Age > 15 AND Age <= 20 Then 1) AS bin4

This is the easiest way to get your data into a histogram-type format, and then select one of the bar charts available in GDS.



回答2:

A way to do it is to create a new field in DataStudio with a formula like this:

CASE 
WHEN Age > 0 AND Age <= 5 THEN "bin1"
WHEN Age > 5 AND Age <= 10 THEN "bin2"
WHEN Age > 10 AND Age <= 15 THEN "bin3"
WHEN Age > 15 AND Age <= 20 THEN "bin4"
ELSE "bin5"
END

After that, you can create a barchart graph with any variable, like Age in this case, as a measurement and the new variable as the dimension to group the data and select count as the representation



回答3:

create a new field call it bin value compute it using integer division e.g. CAST(Age/10 as INTEGER) use it as group by