How to split event values in Google Data Studio with Calculated Fields











up vote
1
down vote

favorite












I'm trying to multiply the event value of a certain Event Action (A) by ($x.xx) and the event value of a different type of Event Action (B) by a different amount ($x.xx).




  • Ex: Event Action A * 1.37

  • Ex: Event Action B * 2.22


I have Google Tag Manager firing events per click, where the Action is the type of click and Label is the URL. In Google Data Studio, I understand I can use a Calculated Field to multiply [Event Value] by [x amount]. But I'm not sure how to separate this based on the event action.



Is it also possible to do this in one field? Such as:



If (Event Action contains "A" then multiply [event value] by [x], else if Event Action contains "B" then multiply [event value] by [y])



Thanks!










share|improve this question


























    up vote
    1
    down vote

    favorite












    I'm trying to multiply the event value of a certain Event Action (A) by ($x.xx) and the event value of a different type of Event Action (B) by a different amount ($x.xx).




    • Ex: Event Action A * 1.37

    • Ex: Event Action B * 2.22


    I have Google Tag Manager firing events per click, where the Action is the type of click and Label is the URL. In Google Data Studio, I understand I can use a Calculated Field to multiply [Event Value] by [x amount]. But I'm not sure how to separate this based on the event action.



    Is it also possible to do this in one field? Such as:



    If (Event Action contains "A" then multiply [event value] by [x], else if Event Action contains "B" then multiply [event value] by [y])



    Thanks!










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm trying to multiply the event value of a certain Event Action (A) by ($x.xx) and the event value of a different type of Event Action (B) by a different amount ($x.xx).




      • Ex: Event Action A * 1.37

      • Ex: Event Action B * 2.22


      I have Google Tag Manager firing events per click, where the Action is the type of click and Label is the URL. In Google Data Studio, I understand I can use a Calculated Field to multiply [Event Value] by [x amount]. But I'm not sure how to separate this based on the event action.



      Is it also possible to do this in one field? Such as:



      If (Event Action contains "A" then multiply [event value] by [x], else if Event Action contains "B" then multiply [event value] by [y])



      Thanks!










      share|improve this question













      I'm trying to multiply the event value of a certain Event Action (A) by ($x.xx) and the event value of a different type of Event Action (B) by a different amount ($x.xx).




      • Ex: Event Action A * 1.37

      • Ex: Event Action B * 2.22


      I have Google Tag Manager firing events per click, where the Action is the type of click and Label is the URL. In Google Data Studio, I understand I can use a Calculated Field to multiply [Event Value] by [x amount]. But I'm not sure how to separate this based on the event action.



      Is it also possible to do this in one field? Such as:



      If (Event Action contains "A" then multiply [event value] by [x], else if Event Action contains "B" then multiply [event value] by [y])



      Thanks!







      google-analytics google-tag-manager google-data-studio






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 at 19:29









      bytebybyte

      347




      347
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          I don't think you can do it in one step in one field but if you do one field (multiplier) as



          CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END


          And then a second field as



          multiplier*[event value]


          EDIT: To take into account [event value] being an aggregate



          AVG(CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END)





          share|improve this answer























          • Thanks for your reply! I created the first field, but the second field throws the following error: Sorry, calculated fields can't mix metrics (aggregated values) and dimensions (non-aggregated values). Please check the aggregation types of the fields used in this formula. This seems to be caused by Event Value being an aggregate [AUT] in the field name.
            – bytebybyte
            Nov 20 at 2:16








          • 1




            Ah. A little annoying! Try wrapping the case statement with AVG() so AVG(CASE WHEN... ELSE 0 END). I've edited my answer
            – Bobbylank
            Nov 20 at 9:20












          • Got it! That seems to have done the trick, thanks Bobby!
            – bytebybyte
            Nov 21 at 14:11











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364667%2fhow-to-split-event-values-in-google-data-studio-with-calculated-fields%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          I don't think you can do it in one step in one field but if you do one field (multiplier) as



          CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END


          And then a second field as



          multiplier*[event value]


          EDIT: To take into account [event value] being an aggregate



          AVG(CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END)





          share|improve this answer























          • Thanks for your reply! I created the first field, but the second field throws the following error: Sorry, calculated fields can't mix metrics (aggregated values) and dimensions (non-aggregated values). Please check the aggregation types of the fields used in this formula. This seems to be caused by Event Value being an aggregate [AUT] in the field name.
            – bytebybyte
            Nov 20 at 2:16








          • 1




            Ah. A little annoying! Try wrapping the case statement with AVG() so AVG(CASE WHEN... ELSE 0 END). I've edited my answer
            – Bobbylank
            Nov 20 at 9:20












          • Got it! That seems to have done the trick, thanks Bobby!
            – bytebybyte
            Nov 21 at 14:11















          up vote
          2
          down vote



          accepted










          I don't think you can do it in one step in one field but if you do one field (multiplier) as



          CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END


          And then a second field as



          multiplier*[event value]


          EDIT: To take into account [event value] being an aggregate



          AVG(CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END)





          share|improve this answer























          • Thanks for your reply! I created the first field, but the second field throws the following error: Sorry, calculated fields can't mix metrics (aggregated values) and dimensions (non-aggregated values). Please check the aggregation types of the fields used in this formula. This seems to be caused by Event Value being an aggregate [AUT] in the field name.
            – bytebybyte
            Nov 20 at 2:16








          • 1




            Ah. A little annoying! Try wrapping the case statement with AVG() so AVG(CASE WHEN... ELSE 0 END). I've edited my answer
            – Bobbylank
            Nov 20 at 9:20












          • Got it! That seems to have done the trick, thanks Bobby!
            – bytebybyte
            Nov 21 at 14:11













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          I don't think you can do it in one step in one field but if you do one field (multiplier) as



          CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END


          And then a second field as



          multiplier*[event value]


          EDIT: To take into account [event value] being an aggregate



          AVG(CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END)





          share|improve this answer














          I don't think you can do it in one step in one field but if you do one field (multiplier) as



          CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END


          And then a second field as



          multiplier*[event value]


          EDIT: To take into account [event value] being an aggregate



          AVG(CASE 
          WHEN REGEXP_MATCH("Event Action","A") THEN [yourmultipliervalueX]
          WHEN REGEXP_MATCH("Event Action","B") THEN [yourmultipliervalueY]
          ELSE 0
          END)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 at 9:22

























          answered Nov 19 at 12:01









          Bobbylank

          938211




          938211












          • Thanks for your reply! I created the first field, but the second field throws the following error: Sorry, calculated fields can't mix metrics (aggregated values) and dimensions (non-aggregated values). Please check the aggregation types of the fields used in this formula. This seems to be caused by Event Value being an aggregate [AUT] in the field name.
            – bytebybyte
            Nov 20 at 2:16








          • 1




            Ah. A little annoying! Try wrapping the case statement with AVG() so AVG(CASE WHEN... ELSE 0 END). I've edited my answer
            – Bobbylank
            Nov 20 at 9:20












          • Got it! That seems to have done the trick, thanks Bobby!
            – bytebybyte
            Nov 21 at 14:11


















          • Thanks for your reply! I created the first field, but the second field throws the following error: Sorry, calculated fields can't mix metrics (aggregated values) and dimensions (non-aggregated values). Please check the aggregation types of the fields used in this formula. This seems to be caused by Event Value being an aggregate [AUT] in the field name.
            – bytebybyte
            Nov 20 at 2:16








          • 1




            Ah. A little annoying! Try wrapping the case statement with AVG() so AVG(CASE WHEN... ELSE 0 END). I've edited my answer
            – Bobbylank
            Nov 20 at 9:20












          • Got it! That seems to have done the trick, thanks Bobby!
            – bytebybyte
            Nov 21 at 14:11
















          Thanks for your reply! I created the first field, but the second field throws the following error: Sorry, calculated fields can't mix metrics (aggregated values) and dimensions (non-aggregated values). Please check the aggregation types of the fields used in this formula. This seems to be caused by Event Value being an aggregate [AUT] in the field name.
          – bytebybyte
          Nov 20 at 2:16






          Thanks for your reply! I created the first field, but the second field throws the following error: Sorry, calculated fields can't mix metrics (aggregated values) and dimensions (non-aggregated values). Please check the aggregation types of the fields used in this formula. This seems to be caused by Event Value being an aggregate [AUT] in the field name.
          – bytebybyte
          Nov 20 at 2:16






          1




          1




          Ah. A little annoying! Try wrapping the case statement with AVG() so AVG(CASE WHEN... ELSE 0 END). I've edited my answer
          – Bobbylank
          Nov 20 at 9:20






          Ah. A little annoying! Try wrapping the case statement with AVG() so AVG(CASE WHEN... ELSE 0 END). I've edited my answer
          – Bobbylank
          Nov 20 at 9:20














          Got it! That seems to have done the trick, thanks Bobby!
          – bytebybyte
          Nov 21 at 14:11




          Got it! That seems to have done the trick, thanks Bobby!
          – bytebybyte
          Nov 21 at 14:11


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364667%2fhow-to-split-event-values-in-google-data-studio-with-calculated-fields%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy