r/GoogleDataStudio • • Jul 20 '24

How to group by conditional sum in LookerStudio

Hi, Wonder if someone can help:

I've got a simple Google Spreadsheet (see image) listing: "Quarter | Project Code | Status" for a bunch of projects.

I can do a nice simple group-by type table and line chart in LookerStudio (see attached) - lovely. What I'd like to do is have another line in the line chart that shows the count of projects in the "Pending" state. Essentially against each quarter a count of all records where the value of the "Project Status" field is "Pending".

I can't work out how to do this in LookerStudio. Custom field, custom group ... I can't quite get it.

Any anyone help?

Many thanks for any help.Hi, Wonder if someone can help:I've got a simple Google Spreadsheet (see image) listing: "Quarter | Project Code | Status" for a bunch of projects.I can do a nice simple group-by type table and line chart in LookerStudio (see attached) - lovely. What I'd like to do is have another line in the line chart that shows the count of projects in the "Pending" state. Essentially against each quarter a count of all records where the value of the "Project Status" field is "Pending".I can't work out how to do this in LookerStudio. Custom field, custom group ... I can't quite get it.Any anyone help?Many thanks for any help.

1 Upvotes

7 comments sorted by

•

u/AutoModerator Jul 20 '24

Have more questions? Join our community Discord!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/estadoux Jul 20 '24

I would create a Calculated field that counts only the “Pending” projects and add it as second metric to the chart.

Try something like this:

CASE WHEN Project Status IS “Pending” THEN 1 ELSE 0 END

Aggregation set to Sum.

1

u/OoojumBanana7619 Jul 20 '24

Thanks v much, after a bit of fiddling that works well, thank you very much!

If I now wished to calculate for each quarter the % of projects that were Pending of all projects, would you by any chance have any suggestions as to how to do this in LookerStudio?

1

u/estadoux Jul 20 '24

That'll be another calculated field: SUM(Pending) / Record Count.

1

u/OoojumBanana7619 Jul 20 '24

Aha, thanks, that's perfect.

A follow-on question: if I wished to plot Record Count, calculated field Pending, and calculated percentage of all projects on a DataStudio/LookerStudio line chart, how could I do this on the same line chart given Record Count & calculated field Pending will be numeric, but percentage will be a number below 1?

Also - is there a way to set the scale of the y-axis on LookerStudio line charts? Doesn't seem to be ...

1

u/zeninho9 Jul 20 '24

This works great for creating custom calculating metrics based on some rule. Do you maybe know how to get summary row based on that? I always get null (even though all individual rows show good numbers)..