Jump to content

This topic is 7929 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi,

I was wondering what could be the difference from these 2 Case Statement structures. Is one more efficient that the other ? Why ?

Case(Value = "A", "Result 1", Value = "B", "Result 2", Value = "C", "Result 3")

Case(Value = "A", "Result 1", Case(Value = "B", "Result 2", "Result 3"))

Just curious about it

Posted

Thanks Dan, I knew I was missing something obvious.

I thought the empty result would have come with :

Case(Value = "A", "Result 1", Value = "B", "Result 2", Value = "C", "Result 3", " "), that is the last " "....

Thanx again. smirk.gif

Posted

as for timing - the nested case seems to be a little bit slower ...

don't know why.

just see attached test file (& correct the calc, that did escape me, dan ..)

caseTest.zip

Posted

had to delete sample records because of upload limit - have a look at the script to create new ones ...

Posted

Hi Christian,

Thank you to reply in depth to my question.

Yes, apart from my errors about the empties, I had tested both methods while creating the calcs for the "Minimum Quantity in Stock" (you surely remember this thread), and I also had the feeling that a nested could be slower from a classic case.

Now, I don't have any idea of what I should see on your sample. My apologizes ; crazy.gif

Posted

>Now, I don't have any idea of what I should see on your sample. My apologizes

Instructions:

Open case-test.fp5

run script "make records" - this will create 20,000 records

the run script "run tests-start"

or just have a look at the results - a negative av(erage) means that case statement # 1 is faster than nested case statement #2.

The file replaces the field "test" using both case statements, recording script start time & end time before each run. In case results the time needed to run the replacement are recorded...

Posted

Well, in my mind, the nested would have eliminated first cases and concentrates the calcs only on the residual "true" results. This seems to me a quicker process.

Not sure I make me clear, but I still think it's strange.

BTW Christian....great test !

Posted

That is a good point. What I mean, is that the resulting data structure for any nested conditional is larger than for single conditionals. More branches to look at and evaluate.

This topic is 7929 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.