I’m pulling data directly from Google Analytics, but I only want to add transactions from specific campaigns or source and medium
Here is the test in DataStudio: https://datastudio.google.com/reporting/2ad4ab07-b7a2-4f0a-b84e-65f043da9afd
I don’t have a spreadsheet because the data is directly connected between DataStudio+Google Analytics
I have a total of Ecommerce transactions, example. That total is on a bar chart. On it I’m trying to add 2 lines:
line 1: transactions of organic source (total 60)
line 2: transactions of paid media source and campaign (total 40)
the two lines sum gives the value of the bar (total 100)
| Source | Medium | Campaign | Transactions |
|---|---|---|---|
| cpc | PMax campaign123 | 30 | |
| cpc | Discovery | 10 | |
| organic | none | 60 |
However, in DataStudio it is not possible to add separate filters. If I add a filter will filter the entire chart, the 2 lines and the bar, because all metrics are the same: transactions.
So I thought about creating metrics with the formulas. I tried CASE, WHEN and SUM, but DataStudio says I’m mixing text with numbers.
I tried:
transactions of paid media source and campaign
SUM(CASE
WHEN REGEXP_CONTAINS(Campaign,"PMAX*") THEN Transactions
WHEN REGEXP_CONTAINS(Campaign,"Smart Shopping*") THEN Transactions
WHEN REGEXP_CONTAINS(Campaign,"Shopping - Catch All*") THEN Transactions
WHEN REGEXP_CONTAINS(Campaign,"Discovery*") THEN Transactions
WHEN REGEXP_CONTAINS(Campaign,"Trueview*") THEN Transactions
WHEN REGEXP_CONTAINS(Campaign,"Bumper*") THEN Transactions
WHEN REGEXP_CONTAINS(Campaign,"VideoAction*") THEN Transactions
WHEN REGEXP_CONTAINS(Campaign,"GDN*") THEN Transactions
WHEN Source/Medium="google / cpc" THEN Transactions
ELSE 0
END)
or only source medium
CASE
WHEN Source/Medium="google / cpc" THEN SUM(Transactions)
END
not work
here are the images:
Thanks in advance for all help!