AnsweredAssumed Answered

If then Add statement

Question asked by JulioSandoval on Jun 26, 2017
Latest reply on Jun 26, 2017 by JulioSandoval

Hello Everyone,

 

I have two tables:

 

Budget Table

Protocol Table

 

They are linked as followed;

 

budget.budget_id = protocol.budget_mid

 

I am creating a calculation field in the Budget table and I need it to add some protocol charges if a protocol field = 1

 

If (protocol.include = 1) ; sum (protocol.chargeamount)

 

My result is that it adds ALL of the values of the charge amount and not the records where protocol.include = 1.

 

I even tried SQL but no success;

 

ExecuteSQL ( "SELECT sum(chargeamount)

AS

Budget_Sum

FROM

Protocol

WHERE

\"Include\" = 1

GROUP BY \"Budget_MID\"

"

; "" ; "" )

 

This only gives me a ? as the result

 

Any light on a solution would be greatly appreciated.

 

Thank you all.

Outcomes