Hi Alexander,
I also had this problem.
The way I solved it was using three calculated fields: Moving Average (Last Week), Moving Average (Prior Week), % Change.
I changed my values and labels to better approximate your use case.
In your post, you talk about “watching” days vs. “before viewed” days. Unless you want to create a persistent derived table (PDT), this is the only way to get it, as far as I know. That means, if you are interested in “watching” 14 days, then you have to set your query to 28 days so that the calculated field can calculate the “before viewed” days.
I will go through the code below. In some parts, you have to insert the path to your measure.
Moving Average (Last week)
Formatting: Percent(2)
sum( if( row() <= 14, ${YOUR_MEASURE}, 0 ) )> / count( if( row() <= 14, ${YOUR_MEASURE}, null ) )
Moving Average (Prior week)
Formatting: Percent(2)
sum( if( row() <= 28 , ${YOUR_MEASURE}, 0 ) )> / count( if( row() <= 28 , ${YOUR_MEASURE}, null ) )
Moving Average (Prior week)
Formatting: Percent(0)
(${moving_average_last_week}-${moving_average_prior_week})/${moving_average_prior_week}
All that is left to do is to set up the comparison.
Making it dynamic
In order to make this whole thing work dynamically, I would replace the hardcoded values (14, 28) with
round(max(row())/2,0)
We can change the logic for the calculated field then.
Moving Average (Dynamic 1st Half)
Formatting: Percent(2)
sum( if( row() < round(max(row())/2,0), ${YOUR_MEASURE}, 0 ) )> / count( if( row() < round(max(row())/2,0), ${YOUR_MEASURE}, null ) )
Moving Average (Dynamic 2nd Half)
Formatting: Percent(2)
sum( if( row() >= round(max(row())/2,0) , ${YOUR_MEASURE}, 0 ) )> / count( if( row() >= round(max(row())/2,0) , ${YOUR_MEASURE}, null ) )
In that way, you will always compare two equal halves no matter how big the timeframe.
I hope this helps!
Let me know if you have any questions about the code!