dhis2-users team mailing list archive
-
dhis2-users team
-
Mailing list archive
-
Message #15134
Re: Problem with the d2:condition function in program operator
Just tried, it works! This will help me & more importantly some users a lot!
Long history of being bitten by operator priorities, so I tend to go the
"non ambiguous way". Are the operator priorities documented somewhere (I
expect the "standard math ones", but better safe than sorry)
Thanks for the quick answer - I'll fill the Jira. A very small fix would be
to add this to the doc - if the doc is on GitHub I'll gladly submit a PR.
Martin
On Wed, Feb 7, 2018 at 9:05 AM, Markus Bekken <markus@xxxxxxxxx> wrote:
> Hi Martin,
> I think it is the parenthesis within the condition that breaks the
> evaluation. When I would always argue for adding the parenthesis for the
> clarity of reading the expression, I think you are in luck here - if you
> remove all the parenthesis your numerical operators will be applied in the
> same order even if you remove them.
>
> Please consider registering an issue on the parenthesis problem if it
> turns out to be the source of the problem.
>
> Best regards
> Markus
>
> 7. feb. 2018 kl. 08:46 skrev Martin Van Aken <martin@xxxxxxxxxxxxxxxx>:
>
> Hello,
> I'm trying to create a program indicator which would evaluate if a ratio
> is equal higher than 80 and return 1 or 0 if not the case.
>
> This is what I have in the expression:
>
> d2:condition('((#{tbLC6IHktf0.CpOPiHrFG8C} * 100) /
> #{tbLC6IHktf0.spWKINz7xwF}) >= 80', 100, 0)
>
> The program indicator show the expression as valid, but when I try to use
> it in a event report, I get this error:
>
> "Illegal arguments, expected 3 arguments: condition, true-value,
> false-value."
>
> I tested the ratio separately and it works.
>
> Any one have any insight of what could be wrong there? I could not find a
> lot of public examples using d2:condition so I may have done a basic
> mistake here.
>
> Thanks !
>
> Martin
>
> --
> *Martin Van Aken - **Freelance Enthusiast Developer*
>
> Mobile : +32 486 899 652
>
> Follow me on Twitter : @martinvanaken <http://twitter.com/martinvanaken>
> Call me on Skype : vanakenm
> Hang out with me : martin@xxxxxxxxxxxxxxxx
> Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
> Company website : www.joyouscoding.com
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help : https://help.launchpad.net/ListHelp
>
>
>
--
*Martin Van Aken - **Freelance Enthusiast Developer*
Mobile : +32 486 899 652
Follow me on Twitter : @martinvanaken <http://twitter.com/martinvanaken>
Call me on Skype : vanakenm
Hang out with me : martin@xxxxxxxxxxxxxxxx
Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
Company website : www.joyouscoding.com
Follow ups
References