Brain Teaser - Solution
Alright, so nobody solved this brain teaser. I’m sure this had nothing to do with people having clients and lives, and everything to do with the original post getting hosed and the challenge being too darn hard anyway ![]()
So here, at long last, is the solution:
mebeliLet (
[
NewSubSummary =( GetNthRecord ( MyTable::MyKeyField ; Get(RecordNumber)-1) <> MyTable::MyKeyFieldкомпютри втора употреба ); //Test if record is the start of a new subsummary. MyKeyField is the sort field for my subsummary part.$on = $val; // $on will always be whatever $val was last
$val = If (NewSubSummary; If ( $val = 1;"" ; 1) ) // switch the value of val
];
$on // if $on=1, then apply the conditional format)
[edit:] Or, in much simpler terms:
Let (
[
$b = If ($b ;"" ;1 )
];
$b
)
To me, the interesting thing here is the way that these variable expressions are handled by FileMaker. First of all, the conditional formatting seems to get evaluated, as one might expect, from top to bottom of the page, allowing you to use variables to keep track of formatting decisions that were made earlier on the page, or even on previous pages. It seems there should be some much cooler implications of this, like multiple title headers and pseudo-headers (don’t know what I mean by that? Neither do I…). The other interesting thing is that the variables here are local variables, but they’re kept active while the whole page is rendered by preview mode, which is what allows me to make reference to the last evaluation of $val and produce the alternating effect (yeah, I know I could just as easily use global variables, but it’s handy to know I don’t have to)
The reason that this gave me a checkerboard on the first try:
was because I had placed the formula on a repeating field, meaning that each conditional format formula was evaluated for each repetition, left-to-right. Once I placed the calc on a regular field, the checkerboard was gone and I had nice alternating rows.
Comments
Leave a Reply
You must be logged in to post a comment.