Creating calculated fields with metrics AND dimentions

Hello,

I have a business and I need to calculate commisions from selling accomodation, which is usually 15 %, but few have 10% instead.

So I wanted to create a calculated field in order to calculate it correctly. So here is what I wanted to do:

SUM(
CASE
WHEN REGEXP_MATCH(Event name, "Name of accomodation") THEN Price * 0.10
ELSE Price * 0.15
END
)

But here is the error (I translated it, so it may be a little different):

We're sorry, but calculated fields cannot combine metrics (agregated values) and dimentions (non-agregated values). Check the types of agregations of the fields used in this formula.

Of course I understand what it means, but I am quite shook, that this wouldn't be possible, as I consider it as a quite simple function. 

If there is anything I could do, please let me know. If you have any other suggestions on how to do this, even in Google Analytics or anywhere, I would be forever grateful. 🙂

2 REPLIES 2

Any reason you are using REGEXP_MATCH instead of just Event name="Name of accomodation" (or CONTAINS_TEXT or something)? A different formula may help.

Do you mean like this:
SUM(
CASE
WHEN CONTAINS_TEXT(Event name, "Name of accomodation") THEN Price * 0.10
ELSE Price * 0.15
END
)
--it reports the same error, and I also tried this:

SUM(
CASE
WHEN (Event name, "Name of accomodation") THEN Price * 0.10
ELSE Price * 0.15
END
)
But it put out this error: Invalid formula. - Invalid input expression. - Unsupported expression