web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

multiple conditions on a calculated fields

(0) ShareShare
ReportReport
Posted on by 193

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:
I have the same question (0)
  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,065 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 764 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 619 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 603 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans