periodOverPeriodDifference Performance

Hi All,

do you know how to increase the performance of periodOverPeriodDifference function? it is very very slow, and if I add multiples, and in the if, it seems both of them are computed even if I just need only one based on parameter. Is there any alternative?

Formula:

ifelse(
    ${execSumControlPeriodType}='Week', sumOver(periodOverPeriodDifference({[%] Metric Value},{[date] period date WMQY}, DAY, 364)*10000,[{[date] period date WMQY}]),
    ${execSumControlPeriodType}='Month' or ${execSumControlPeriodType}='Quarter', sumOver(periodOverPeriodDifference({[%] Metric Value},{[date] period date WMQY}, DAY, 365)*10000,[{[date] period date WMQY}]),
    NULL
)

You can try and play around with lag / lead functions which can replicate what you are trying to do. However, there is no way to speed up the period over period difference from what exists in quicksight.