This isn’t really true. The exact point of the call(
function is to allow procedure code to be used in a formula. I think @danbolling has done this correctly, so the question remains, why didn’t it work?
I think the answer is the first parameter of the call(
function, which specifies the database. Dan has left this empty, so that it specifies the current database. I think the problem is that while the Morph dialog is open and your looking at the preview of the formula (the After column in the dialog), the current database is not Dan’s database, but an internal database that Panorama uses to implement the Morph dialog. So the call(
function fails because it can’t find the calc_3
procedure in Panorama’s _MorphFieldLib database. This is really a bit of a bug on Panorama’s part, it should use the user’s database as the default when previewing a formula. I’ve gone ahead and added this to the issue tracker.
If Dan had gone ahead and pressed the Morph button, I think it would have worked correctly, it’s just the preview that doesn’t work. However, I don’t blame him for not proceeding to press the Morph button – in his shoes I probably wouldn’t have either.
So, I think if Dan’s formula had been modified to explicitly specify the database, it would have worked:
call("dan's database","calc_3")
Or, it also would have worked if he had written a short procedure instead of using the Morph Current Field dialog, like this:
formulafill call("","calc_3")
All this being said, I think @KJM has the best answer here, using the ?( function allows this to be done without using any procedure code and will be significantly faster. If the database is small that won’t matter, but for a large database this could make a difference. If you are not familiar with the ?( function, it is similar to the if statement but within a formula instead of within procedure code.
Or, another way to do this particular example is with the switch( function, like this:
switch(type,"a",field2*200,"b",field2*17,0)
Some of you may not be aware of this function since it is new to Panorama X.