Nested IF Statements

Moderators: Moderators, Tech Support

Post Reply
gtackett
Posts: 34
Joined: Fri Nov 05, 2004 12:21 pm
Location: Redeemer Covenant Church
Contact:

Nested IF Statements

Post by gtackett »

I am looking for a way to test a variable for a particular value and then have the output be some simple text. For example, the following expression works good:

IIF(PCPLUS.subacct="100","Pastoral","Administrative")

However I have twelve tests to do. I could do a nested IIF statement but was wondering if FOXPRO had a better logical function. There was a old CASE function from my Pascal days. I looked thru

http://msdn.microsoft.com/library/defau ... ctions.asp

but couldn't find a quick answer.

Am I stuck with the nested IF statements?

I saw a DO CASE commande but figured that was to complicated for the Custom Reports module. Can I build a CASE statement from within Custom Reports?
Garland Tackett, Director of Administration
Redeemer Covenant Church
Tulsa OK
Using PC+ Ver 10.4

Tracy
Program Development
Program Development
Posts: 463
Joined: Fri Sep 05, 2003 3:08 pm
Location: PowerChurch Software
Contact:

Post by Tracy »

A case statement cannot be done with in the report. The report variables and texts are limited to 254 characters (If I remember correctly). To maintain some clarity in the nested IIF(), use the Variables available in the report and nest them. Remember variable names in the report are named what you like (var1) and used in the report with an ‘m.’ in front of them (m.var1).
Tracy

gtackett
Posts: 34
Joined: Fri Nov 05, 2004 12:21 pm
Location: Redeemer Covenant Church
Contact:

Post by gtackett »

Thank you for the response! I hadn't thought of the variables idea - that's a good one.
Garland Tackett, Director of Administration
Redeemer Covenant Church
Tulsa OK
Using PC+ Ver 10.4

gtackett
Posts: 34
Joined: Fri Nov 05, 2004 12:21 pm
Location: Redeemer Covenant Church
Contact:

Post by gtackett »

I tried your suggestion. Here is the expression I tried to build:

IIF(subacct=100,"Pastor",IIF(subacct=200,"Admin",IIF(subacct=310,"Wor",
IIF(subacct=400,"Evan",IIF(subacct=500,"Cong",IIF(subacct=610,"Disc",
IIF(subacct=690,"Educ",IIF(subacct=691,"Nur",IIF(subacct=695,"StuMin",
IIF(subacct=696,"Pre",IIF(subacct=700,"Miss","Prop")))))))))))

(I trouble typing all this in so I had to include the carriage returns in this post. These CR's are obviously not in my expression.)

This was too many characters. Any suggestions?
Garland Tackett, Director of Administration
Redeemer Covenant Church
Tulsa OK
Using PC+ Ver 10.4

Tracy
Program Development
Program Development
Posts: 463
Joined: Fri Sep 05, 2003 3:08 pm
Location: PowerChurch Software
Contact:

Post by Tracy »

I suggested nesting the IIF() with variables, create something like the following variables. (Order does matter, create them in nested order, as shown.)

IIF_Miss
IIF(subacct=700,”Miss”,”Prop”)

IIF_Pre
IIF(subacct=696,”Pre”,m.IIF_Miss)

IIF_StuMin
IIF(subacct=695,”StuMin”,m.IIF_Pre)

If these were the only three variables (you have more), the only variable needed to used in the report field object is m.IIF_StuMin.
Tracy

gtackett
Posts: 34
Joined: Fri Nov 05, 2004 12:21 pm
Location: Redeemer Covenant Church
Contact:

Post by gtackett »

That is so cool. I will try it out. I guess one downside is that I have to create this for each report. Any way to create global variables instead of just local?

We're never satisfied, are we? :D
Garland Tackett, Director of Administration
Redeemer Covenant Church
Tulsa OK
Using PC+ Ver 10.4

Tracy
Program Development
Program Development
Posts: 463
Joined: Fri Sep 05, 2003 3:08 pm
Location: PowerChurch Software
Contact:

Post by Tracy »

There is not a way to create global variables at this time. Send a request to the wishlist.
Tracy

Post Reply