Question

caculate cumulative total month by month every year since 2010

  • 10 February 2021
  • 0 replies
  • 9 views

Hello,
Please I want to create a dashboard calculate  :

  • the turnover month by month and the cumulative total of the brand since 2010.
  • the progression of turnover (prog_turnover) of each month n vs year n-1/month n, you can see a part of my code

Thank you

measure: total_turnover {
type: sum
value_format_name: eur
drill_fields: [detail*]
sql: ${turnover} ;;
}

filter: date_filter {
type: date
}

measure: total_turnover_select_month {
type: sum
value_format_name: eur
label: "CA HT"
sql: CASE
WHEN {% condition date_filter %} CAST(${date_purchase_date} AS TIMESTAMP) {% endcondition %}
THEN ${turnover}
END ;;
}

measure: total_turnover_select_monthly {
type: sum
value_format_name: eur
label: "CA HT"
sql: CASE
WHEN {% condition date_filter %} CAST(DATE_ADD(DATE(${dte_vente_date}), INTERVAL 1 YEAR) AS TIMESTAMP) {% endcondition %}
THEN ${turnover}
END ;;
}

measure: prog_turnover_select_month {
value_format_name: percent_2
type: number
sql: 1.0 *(${total_turnover_select_month}-${total_turnover_select_monthly})/NULLIF(${total_turnover_select_monthly},0);;
}

 


0 replies

Be the first to reply!

Reply