Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula Help - Make more elegant please - Variables?

Status
Not open for further replies.

Cort

MIS
Apr 16, 2002
154
US
Can you help me make this formula more elegant and efficient. I know it can be done but I haven't been able to quite get variations other than this to work.

CR 9.0:

Code:
if Month(minimum(LastFullMonth)) = 1 then {PAIDMONTH} else  
if Month(minimum(LastFullMonth)) = 2 then {PAIDMONTH_2} else
if Month(minimum(LastFullMonth)) = 3 then {PAIDMONTH_3} else  
if Month(minimum(LastFullMonth)) = 4 then {PAIDMONTH_4} else  
if Month(minimum(LastFullMonth)) = 5 then {PAIDMONTH_5} else  
if Month(minimum(LastFullMonth)) = 6 then {PAIDMONTH_6} else  
if Month(minimum(LastFullMonth)) = 7 then {PAIDMONTH_7} else  
if Month(minimum(LastFullMonth)) = 8 then {PAIDMONTH_8} else
if Month(minimum(LastFullMonth)) = 9 then {PAIDMONTH_9} else  
if Month(minimum(LastFullMonth)) = 10 then {PAIDMONTH_10} else  
if Month(minimum(LastFullMonth)) = 11 then {PAIDMONTH_11} else  
if Month(minimum(LastFullMonth)) = 12 then {PAIDMONTH_12} else
0

I'm trying to write more effecient formulas and I'm sure that there is a way to declare Month(minimum(LastFullMonth)) as a variable then insert it into the field name to dynamically choose the correct field but I can't get it to work.

Thanks, as always, for the great help.
 
You could use :

Local NumberVar Array PaidMonth := MakeArray({PAIDMONTH},{PAIDMONTH_2},{PAIDMONTH_3},{PAIDMONTH_4},{PAIDMONTH_5},{PAIDMONTH_6},{PAIDMONTH_7},{PAIDMONTH_8},{PAIDMONTH_9},{PAIDMONTH_10},{PAIDMONTH_11},{PAIDMONTH_12});
Local NumberVar tmpMonth := Month(minimum(LastFullMonth));
PaidMonth[tmpMonth];

Or:

Local NumberVar tmpMonth := Month(minimum(LastFullMonth));
if tmpMonth = 1 then {PAIDMONTH} else
if tmpMonth = 2 then {PAIDMONTH_2} else
if tmpMonth = 3 then {PAIDMONTH_3} else
if tmpMonth = 4 then {PAIDMONTH_4} else
if tmpMonth = 5 then {PAIDMONTH_5} else
if tmpMonth = 6 then {PAIDMONTH_6} else
if tmpMonth = 7 then {PAIDMONTH_7} else
if tmpMonth = 8 then {PAIDMONTH_8} else
if tmpMonth = 9 then {PAIDMONTH_9} else
if tmpMonth = 10 then {PAIDMONTH_10} else
if tmpMonth = 11 then {PAIDMONTH_11} else
if tmpMonth = 12 then {PAIDMONTH_12} else
0

But you can't dynamically change the name of the field like:

{PAIDMONTH_tmpMonth}

Hope this helps

Reebo
 
Thanks for the reply something along the lines of {PAIDMONTH_tmpMonth} was exactly what I was looking for. Figured that it could be done but suppose not.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top