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.
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.
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156