caspii
September 17, 2021, 8:10am
1
I have a field in my DB which stores an integer between 1-12. This determines the AB test group the user is in: odd means group A, even means group B.
There seems to be no simple way of calculating which group the user is in. Ideally I would create a custom column with the values "ODD" or "EVEN".
How do I do this in Metabase?
flamber
September 17, 2021, 8:49am
2
Hi @caspii
You can with Custom Expressions: https://www.metabase.com/learn/questions/custom-expressions
case([Field] / 2 = floor([Field] / 2), "Even", "Odd")
caspii
September 17, 2021, 9:12am
3
Great thanks!
Are there plans to add a mod operator?
flamber
September 17, 2021, 9:27am
4
@caspii What operator? Please provide context - perhaps a link.
smurray
September 17, 2021, 4:39pm
5
Modulus is often written as %
or mod
or modulo
or similar. See:
It's super helpful for identifying even/odd or every other row in a result set.
flamber
September 17, 2021, 4:50pm
6
caspii
September 17, 2021, 6:05pm
7
What @smurray said. I think it's a basic computer operation that should be supported by Metabase.
I'll add a feature request.
PS Metabase is a fantastic tool. Thanks for making it.
caspii
September 17, 2021, 6:13pm
8
1 Like
flamber
September 17, 2021, 6:22pm
9
@caspii Remember to upvote issues by clicking on the first post of an issue.
The reason why it's not possible is because Custom Expressions are not a real programming language. There are a lot of functionality we want to add, but it has been quite difficult to just get to the state it's currently in. But we will add a lot more in the future.
1 Like