When to use Case or If statement?
Is there a guideline as to when a Case() statement should be used instead or in preference to an If() statement. Is there a difference in the overhead or the speed of porforming either?
The first link
Afterwards, when I remembered your question, I created a modified script to test an unstored 5-level nested If calculation and compared this with a Case statement with 5 arguments on this 36,500 record loop. I did 5 passes for each test, so, approximately 182,500 records per test. In my results, the Case statement was approximately 4% faster.
Case vs If
Tip 2: Case versus IF StatementsCase statements were introduced in version 3.0 of FileMaker. They perform exactly function as an If statement, however can greatly simplify calculations. Case statements are best used in place of a nested If statement. This is best illustrated by examining two calculations which will return a number in words (in the calculated field Display), based on a numeric entry (in the field Number) Using an If statement: If(Number = 1, "One", If(Number = 2, "Two", If(Number = 3, "Three","")))Using a Case statementCase(Number = 1,"One", Number=2, "Two", Number=3,"Three")
FILEMAKER: Nested If Statements Vs Case Statements
If ( test; resultOne; resultTwo )
Thanks Davidanders - clearly the Case() statement wins hands down in terms or being easier to read as the complexity increases.
Is there a performance overhead difference though?
Retrieving data ...