Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2004
    Location
    amsterdam
    Posts
    31

    Unanswered: OPAL in a report

    I'd like to do calculations in a report, based on the value of a variable. This has to yield a new field in the report with text. A calculated field cannot contain more than one statement (?), thus I cannot use the iif statement (only two values). For instance, if my variable has the value <10, the new variable should contain "low", between 10-20 "middle" and >20 "high", to be printed on the report.
    This can easily be done in OPAL, but how to use this in a report? I can't attach code to a variable.

  2. #2
    Join Date
    Oct 2003
    Posts
    107
    I don't know any way to do that off the top of my head. You may need to add an extra field for this notation and apply the correct label during a scan loop right before the report is displayed.

  3. #3
    Join Date
    Feb 2004
    Location
    Gold Coast, Queensland, Australia
    Posts
    15

    Re: OPAL in a report

    Originally posted by fepsy
    I'd like to do calculations in a report, based on the value of a variable. This has to yield a new field in the report with text. A calculated field cannot contain more than one statement (?), thus I cannot use the iif statement (only two values). For instance, if my variable has the value <10, the new variable should contain "low", between 10-20 "middle" and >20 "high", to be printed on the report.
    This can easily be done in OPAL, but how to use this in a report? I can't attach code to a variable.

    Hi,
    Did you know that you can nest iif's?
    e.g. iif(my_variable<10,"low",iif(my_variable>20,"high" ,"middle"))
    This will achieve the above in one statement that is in your field calculation.
    The variable my_variable could be stored in a table in your private directory and referenced directly by the field calculation
    e.g. iif([:priv:Temptbl.my_variable]<10,"low",iif([:priv:Temptbl.my_variable]>20,"high","middle"))
    Let me know how you go.

    Cheers.
    Last edited by Yuri Korin; 03-06-04 at 10:35.
    YuriK

  4. #4
    Join Date
    Feb 2004
    Location
    Gold Coast, Queensland, Australia
    Posts
    15

    Talking Re: OPAL in a report

    Originally posted by Yuri Korin
    Originally posted by fepsy
    I'd like to do calculations in a report, based on the value of a variable. This has to yield a new field in the report with text. A calculated field .
    .
    .
    .
    e.g. iif([:priv:Temptbl.my_variable]<10,"low",iif([:priv:Temptbl.my_variable]>20,"high","middle"))
    Let me know how you go.

    Cheers.

    Sorry, I'm not sure how those icons got into the body of the second example but here it is, cleared of icons.

    iif([:priv:Temptbl.my_variable]<10,"low",iif([:priv:Temptbl.my_variable]>20,"high","middle"))
    Last edited by Yuri Korin; 03-08-04 at 03:25.
    YuriK

  5. #5
    Join Date
    Feb 2004
    Location
    Gold Coast, Queensland, Australia
    Posts
    15

    Re: OPAL in a report

    This is driving me nuts. Please replace the icon with ":P"

    Cheers,
    YuriK

  6. #6
    Join Date
    Oct 2003
    Posts
    107
    Yuri, edit your post and disable the smilies (checkbox at bottom). Also, thanks for the info on nesting the iifs!

  7. #7
    Join Date
    Feb 2004
    Location
    Gold Coast, Queensland, Australia
    Posts
    15

    Wink

    Originally posted by lmckelvy
    Yuri, edit your post and disable the smilies (checkbox at bottom). Also, thanks for the info on nesting the iifs!

    Thanks for that. I didn't know that you could do either of those.

    Cheers,
    YuriK

  8. #8
    Join Date
    Jan 2004
    Location
    amsterdam
    Posts
    31
    This is great, thanks! Never thought of this solution, I'll check if this works in PDOX4.5 too, it always annoyed me.
    I didn't see any smileys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •