Let([ T = TotalInvoice ; I = Interest ; D = Get ( CurrentDate ) - invoice date ]; Case ( D ≥ 30 ; T + I ; T ))
TotalInvoice = "T" ;
interest = "I";
date = Get (currentDate) - invoice date
Case ( date ≥ 30 ; T + I ; T )
I'll take a stab at it, though another may correct me.
Let ( [TotalInvoice = "T" ; interest = "I"; Get (currentDate) - invoice date = "date" ]; Case ( date ≥ 30; T + I); T)
The onboard help shows putting the variable to be set first, not second:
so Let ( [TotalInvoice = "T"... should be Let ( T = TotalInvoice ; ....
The way you have it, you are setting TotalInvoice equal to "T" rather than the way you want it.
And the parenthesis causing the issue is probably the extra one you have in your Case statement.
Case (date >= 30 ; T+I ; T ) you have an extra ")" in yours that belongs at the end of the expression instead.
Edit: wow, two others beat me to it...must be typing slow this morning.
Thanks everyone for your quick responses! I had two problems - one was reversing the let variables and the other was the parentheses in the case expression.
The format for assigning variables using a let function is VariableName = Expression. You are assigning the character "T" to a variable named TotalInvoice, The character "I" to a variable named intrest, and you are trying to assign the string "date" to something that is not a variable. Also, your close parenthesis in the case statement should be after T. Format should be case(test;result; test2;result2; default).
I am going to make a guess that TotalInvoice is a field in your database, along with intrest and invoice date. If that is the case, your let statement should look like:
T = TotalInvoice;
I = intrest;
date = Get(CurrentDate) - invoice date];
Case (date ≥ 30; T + I; T)
I had to take a phone call. Slowed me down on the answer
You solved my third problem - how to have more than one "case".
A useful practice is to make the result a variable as well. This makes it easier to troubleshoot. E.g.:
Let([ a = foo ; b = bar ; result = Case( something; a ; b ) ] ; result )
If I get an error or unexpected result, I can throw the calc into the Data Viewer (assuming we have FileMaker Advanced) and change the last "result" variable to "a" or "b" etc. to figure out what's going on.