>>Hi all,
>>
>>I need to build a conditional SUM and I want to include it in a Report.
>>I have the following instruction that works in an SQL statement but not like a fixed field at report´s feet.
>>
>>SUM(IIF(a.plan,a.val_cuot,a.amount)) AS n_amount.
>>
>>TIA
>
>Marcelo, you can use report variable for that. Go to VFP menu/Report/Variables create a n_amount variable there, set "Initial value" to 0 and put the expression
>
>IIF(a.plan, n_amount+a.val_cuot, n_amount+a.amount)
>
>in "Value to store". Set "Calculation" to "Nothing"
>then show your variable in the report footer.
>
>Nick
Another way to do this - declare the array n_amount[1]
SELECT SUM(IIF(plan, val_cuot, amount) from myTable to ARRAY n_amount
before the REPORT FORM...
and show n_amount[1] in report field
Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro
"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison