Revit: Choosing a Maximum Value in a Formula

Nothing earth-shaking here, just recording this so the next time I need to do it, I do not have to put it together from scratch.

The formula to get the larger value of two parameters is relatively easy:

if(A > B, A, B)

But if you need to pick the maximum value of three parameters, it gets a little trickier:

if(A > C, if(A > B, A, B), if(B > C, B, C))

Expanding that to the maximum of four values requires something like the following:

if(A > D, if(A > C, if(A > B, A, B), if(B > C, B, C)), if(D > C, if(D > B, D, B), if(B > C, B, C)))

I am hoping I will not ever need to get the maximum of five or more values.
Read more