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
Sohaib Cheema
764
User Group Leader
Martin Dráb
619
Most Valuable Professional
André Arnaud de Cal...
603
Super User 2025 Season 2