Data Studio
2.8K members online now
2.8K members online now
Ask questions about Data Studio
Guide Me
star_border
Reply

ROUNDing a BQ dimension

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

I have a BQ database that contains the age of a user. I want to get only the decade of the age (34->30, 45->40) so I try doing something like that ROUND(age / 10, 0) * 10 but it keeps popping an error message although I don't understand why.

 

thanks

ROUNDing a BQ dimension

Participant ✭ ✭ ☆
# 2
Participant ✭ ✭ ☆

I believe age is a dimension rather than a metric (though I'm not 100% sure), so this could be the reason it won't let you. 

ROUNDing a BQ dimension

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thanks for the reply, it is a dimension. Why can't a dimension be rounded? I'm not aggregating or doing anything that will make the end result dependent on another source, It is just a "cosmetic" change.

Marked as Best Answer.
Solution
Accepted by topic author Yotam O
May 2017

ROUNDing a BQ dimension

Participant ✭ ✭ ☆
# 4
Participant ✭ ✭ ☆

A dimension is effectively a label, not a number. A dimension might look like a number, but it's not calculable like a metric is. You could probably do some sort of case statement to define each age into a bucket, but that would be a really long formula. 

 

I'm not familiar with BQ. Is it possible to define a segment within BQ that lumps together the ages into buckets?

. Re: ROUNDing a BQ dimension

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

I used a semi-long case statement in the end as it turned out to not be that long.

 

Thanks for the help.