Question

Reference line for last x days average

  • 16 August 2017
  • 4 replies
  • 156 views

Hi I have a scenario where I want to plot a graph for 90 day stats with a reference line displaying average of last 14 days.


Dimension: date_field


measure: Stat_vale


reference line: Last 14 day stat avg



ex table:


date:8/10 stat_value: 100


date:8/11 stat_value: 200


date:8/12 stat_value: 1000







Please help


4 replies

Userlevel 3

Hi @nbk11kk,



You can use a table calculation (in the Calculations tab above your results table) to produce a reference line:


mean(if(row()<=14, ${stat_value}, null))



Make sure that your date_field dimension is ordered with the latest dates at the top.



Thanks Chris…what if I want to ignore weekends from last 14 days.Is that possible to achieve in table calculations

Userlevel 3

Hi @nbk11kk,



Would it satisfy your use case to filter out weekends from the results entirely? If so, you can make date_field a dimension_group and filter on day_of_week or day_of_week_index: https://docs.looker.com/reference/field-params/dimension_group

Thank you so much

Reply