I have a calculation that takes some processing time where the result shall be rounded. But the rounding shall be relative to the result of the calculation. So the step parameter for the rounding function needs to be e.g. 1% of the result of the calculation.
where x is my complex and performance-killing calculation.
but I need "step" to be dynamic to reflect the magnitude of x. E.g. billions rounded to millions and millions rounded to thousands.
I am using now
Round( x , pow( 10 , LEN(text(round( x ) ) )-3 ) )
But as you see the calculation x is used twice AND I need 4 additional functions (round, text, len and pow). Is there a more efficient way?
I'm not sure that there is much potential to improve the performance unless you could optimize the calculation of x itself and/or using a simplified version of it to define the length (you don't need the exact number here else just the magnitude).
Depending on where this expression is used you might be able to split it into two expressions, for example if it's used within a KPI you could calculate x within a variable and within the KPI it's just an adjusting of this variable-value. Within a table you could use two or maybe more expressions for this approach and referring to it per label or column() and/or grabbing the value with an interrecord-function like above/before - just with the aim to benefit from some kind of caching of the results.
I believe the interrecord-functions might rather work as the referring-approach because I'm not sure if here any caching is applied or if it's just some shortcut to transfer the real expressions.
How does your x look like? Maybe there is something to improve. Also the datamodel could impact the calculation - if for example all relevant fields are transferred into a single table.