Explore this snippet with some demo data here.
Horizontal Bar charts are ideal for comparing a particular metric across a group of values. They have bars along the x-axis and group names along the y-axis. You just need a simple GROUP BY to get all the elements you need for a horizontal bar chart:
SELECT
AGG_FN(<COLUMN>) as metric,
<GROUP_COLUMN> as group
FROM
<PROJECT.SCHEMA.TABLE>
GROUP BY
groupwhere:
AGG_FNis an aggregation function likeSUM,AVG,COUNT,MAX, etc.COLUMNis the column you want to aggregate to get your metric. Make sure this is a numeric column.GROUP_COLUMNis the group you want to show on the y-axis. Make sure this is a categorical column (not a number)
In this example with some Spotify data, we'll compare the total streams by artist:
select
sum(streams) streams,
artist
from spotify.spotify_daily_tracks
group by artist