Search code examples
google-analyticsbusiness-intelligencelooker-studio

Google Data Studio Sum with Conditions


I have one metric and one dimension I need to create a calculated field like SQL Query:

sum(new_users) where event_action= "manual_widget_click" / Total_new_Users

I can not understand the logic of formulas in Data Studio. Not here standard functions like 'sumif' or 'where'.... only 'Case When'. But I can not put together a formula...

enter image description here


Solution

  • It can be achieved by breaking down the formula into 2 Calculated Fields.

    First :

    CASE
      WHEN event_action= "manual_widget_click" THEN new_users
      ELSE 0
    END
    

    Then :

    SUM(event_action= "manual_widget_click" THEN new_users) / Total_new_Users