Math function abs

Hello,

I regularly need an absloute value function in dgraph queries.

Would it be possible to add abs( <exp> )?

Today, I tried with:

math(cond(var<0, -var, var))

But when var is empty, it crashes with: Expected a value variable in cond but missing

So I ended up doing:

math(max(var, 0)-min(var, 0))

which doesn’t care if var is empty.

2 Likes

Hey @myo,

You can create a feature request for this on github. We’ll be able to work on it.

Hi @Neeraj, I thought feature requests moved here. The github issue section is now closed.

Oh, I totally forgot about that. Made this a feature request.
Thanks

@Neeraj and @myo not exactly. This place /users/dgraph is used to community conversations and questions. Issues must go to /issues/dgraph/.

1 Like

Thx @MichelDiz, I’m not used to the new organisation yet.
I thought issues were set as tags, not from a given URL or path.
If I click on the menu, then issues, I can find this thread, so I don’t understand what the issues section is.

The Issues category that you see near the title is same as the Issues section that Michel talked about in the above conversation. Issues>Dgraph is the subcategory. :slight_smile:
Also, you can see all the issues for dgraph subcategory at http://discuss.hypermode.com/c/issues/dgraph/.

1 Like