Jump to content

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

Recommended Posts

Posted

This is probably one of those simple things that I simply can't see ...

The attached file has a field called cRandom. When I attempt to sort on this field, it doesn't sort properly and I cannot understand why. I think it is because it is unstored and random and it changes it's display of the number after it sorts? So sorting comes before unstored calculation refreshes?

I cannot see the logic in why it does not sort properly. Ideas please?

random questions.zip

Posted

I dont know but if you dont store the calculation results, you will always be reevaluating the calc.

I think Daniel from Weetbix threw this out a few months ago on the chatroom. This is where relationships are involved or some other type of fix is required.

-i

Posted

I believe it evaluates twice - once for the sort, and once for the display.

I find it strange. Not all unstored calculations evaluate twice (one for sort then once for display) do they? It is not like it needs to evaluate its order again after it sorts; if it were based upon Get ( RecordNumber) then I might understand it but it is based upon the single static Get ( FoundCount ).

So it works - it just does not display the same numbers it used for the sort. It is certainly an unexpected behavior at the least.

Hi Ian, thanks. The calc needs to be unstored because the record sets will change.

Posted (edited)

It is not like it needs to evaluate its order again after it sorts;

No, but after sorting it still needs to come up with a number to draw in the box on the layout. Note that it re-evaluates when after you sort the records by another field; why should sorting by this field be any different?

Edited by comment
Posted

So ... ALL unstored calculations must evaluate when a record set is sorted? And then must also re-evaluate when displaying the result? Even if the field being sorted is not referenced in the unstored calculation? Or is Random() unique?

I now wonder if it is not wise to sort a large record set on a null layout first then, before switching to a layout which displays the unstored calculations. They should not evaluate if they are not displayed, right? Thanks for helping me on this, Michael. :laugh2:

ADDED: I realize of course to use null layouts or form when looping, etc ... I just want to pin this down a bit more on how sorting forces re-evaluation of records...

Posted

So ... ALL unstored calculations must evaluate when a record set is sorted?

No, only the ones you are sorting by (if you are sorting by any).

And then must also re-evaluate when displaying the result?

Yes - if they are on the layout.

IOW, when you sort by cRandom AND cRandom is on the layout, it must be evaluated twice. If the field is not on the layout, it needs to evaluate only once, for the sort itself.

Posted

BTW, a small test I've made shows that those are not only evaluations taking place. For example, even if the field is not on the layout, the current record evaluates it twice during the sort. I don't know why that happens.

Posted

Ah, I had read your post before you changed it. "Note that it re-evaluates when after you sort the records by another field;" so I was still thinking you said WHEN you sort. Now it all fits and since we do not care about the random number being displayed and since this is smaller record set, it will work just fine. Thank you!!

Can you share your test method?

Posted

Can you share your test method?

it just captures all evals into a $$variable, e.g.

Let ( [

r = Random ;

$$r[serialID] = $$r[serialID] & ¶ & r

] ;

r

)

Then you observe the results in data viewer.

Posted

So this is not a simple issue at all, You can't sort via random numbers ? Or you can ? if so, how , why ? Or have you given up LaRetta?

-ian

This topic is 4792 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.