I’m having trouble figuring out how to count publications in my Looker data set by year and author. In my Looker explore the data Looker table results look like this:
Pub_id | year | author | author_id |
---|---|---|---|
1_1 | 2021 | john | 5.5 |
1_2 | 2020 | john | 5.5 |
1_3 | 2021 | jane | 2.0 |
1_4 | 2021 | jane | 2.0 |
1_5 | 2019 | garth | 3.6 |
1_6 | 2013 | wayne | 1.7 |
I want to create a bar chart that gives me the total number of publications per year, so:
x
x
x x x x
2013 2019 2020 2021
My struggle is getting the count or aggregate of the count correct.
I’m also trying to crate an aggregate count by authors, so output would look like:
Author | Number of publications |
---|---|
John | 2 |
Jane | 2 |
Wayne | 1 |
Garth | 1 |
Thanks for help or advice!
Both of these aggregations should use a single dimension
and a single measure
. For both, the measure
should be a simple count
:
view: my_view {
measure: number_of_publications {
type: count
}
}
Then in the explore, you should only select this measure and a single dimension (year
for the first one and Author
for the second), and you'll end up with a table like the one you posted above for Author
.
Once you have the table, just select the bar chart type and you should be good to go.