Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

multiple conditions on a calculated fields

Posted on by 191

How can I create a nested Conditional field in GP Report Writer.  Here is what I need

IF Field A = 1 then Field B minus 6

IF Field A = 2 then Field B minus 13

IF Field A = 3 then Field B minus 20....and so on. 

Categories:
  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,928 Most Valuable Professional on at
    RE: multiple conditions on a calculated fields

    You have a number of options available to you

    Old school: You can create multiple conditional calculated fields:

    Calc A: Conditional Integer - If Field A = 3 Then Field B - 20 Else Field B - ?

    Calc B: Conditional Integer - If Field A = 2 Then Field B - 13 Else Calc A

    Calc C: Conditional Integer - If Field A = 1 Then Field B - 6 Else Calc B

    etc.

    Smarter: Or you can use the RW_Token() Report Writer function I added to core GP for v7.0. RW_Token() returns a string value based on the separator character and position number passed in. So we can use it to get the value to subtract for each value of Field A. Then use a second calculated field to perform the subtraction after converting the string to a long integer.

    Calc A: Calculated String - RW_Token("6,13,20,?", ",", Field A)

    Calc B: Calculated Integer - Field B - STR_LNG(Calc A)

    Completely Custom: Or with GP Power Tools you can create your own custom RW Function to perform any calculation you want including accessing tables if needed. (GPPT Portal: http://WinthropDC.com/GPPT)

    More info:

    https://winthropdc.wordpress.com/2008/09/01/using-the-built-in-report-writer-functions/

    https://winthropdc.wordpress.com/2010/06/01/using-rw_token-to-parse-runtime-build-numbers/ 

    Regards

    David

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans