Hi Team, I'm trying to build a Turnover YoY line c...
# gooddata-cloud
c
Hi Team, I'm trying to build a Turnover YoY line chart in GoodData, showing the monthly trend and segmented by channel (Club vs Hotel), but all the values are coming through as 0. Does anyone know how I should set this up in GD? turnover_yoy=sum(turnover_ThisYear)/sum(turnover_LastYear), trend by month and segmented by channel(club, hotel). turnover_ThisYear= SELECT SUM({fact/FCT_DAILY_PERFORMANCE.TURNOVER}), Turnover_LastYear=SELECT SUM({fact/FCT_DAILY_PERFORMANCE.TURNOVER}) FOR PREVIOUS({label/date.year}), Turnover_yoy=SELECT {metric/turnover_sum}/ {metric/turnover_ly_for_pre_year} - 1. link: 06. Monthly Performance - GoodData Cloud view name: Turnover YOY by Channel
k
Looking at your chart and metric definitions, the issue is likely with how
FOR Previous
works in this context. Here's what's happening and how to fix it: Why You're Getting 0% Your YoY metric is:
Copy code
SELECT {metric/turnover_sum} / {metric/turnover_ly_for_pre_year} - 1
where
turnover_ly_for_pre_year
uses:
Copy code
SELECT SUM({fact/FCT_DAILY_PERFORMANCE.TURNOVER}) FOR PREVIOUS({label/date.year})
The problem:
FOR Previous
strictly follows the date attribute you specify — in this case
date.year
. However, your visualization is broken down by Month/Year (a more granular date attribute). Since
FOR Previous
does not adapt to the visualization's granularity, it may not be returning the values you expect at the monthly level, resulting in a division that produces 0 or near-0. [Functions for Past Periods] Recommended Fix: Use FOR PreviousPeriod Instead
FOR PreviousPeriod
adapts to the most granular date attribute in the visualization. Since your chart uses Month/Year, it will automatically shift by month, which is what you want for a monthly YoY trend. [FOR PreviousPeriod] Update your Last Year metric to:
Copy code
SELECT SUM({fact/FCT_DAILY_PERFORMANCE.TURNOVER}) FOR PreviousPeriod({label/date.year})
> Important: Even though
FOR PreviousPeriod
adapts to the visualization's granularity (month), you still need to specify the date dimension (e.g.,
{label/date.year}
) to indicate which date dimension to use, especially if your workspace has multiple date dimensions. Additional Checks 1. Date filter: Make sure you have a date filter applied to the visualization. If the date filter is set to All time, time-over-time comparison cannot be enabled. [Time-over-Time] 2. Segmentation: Your setup of Trend by = Month/Year and Segment by = Channel Type looks correct for a line chart. Just ensure only one metric is in the Metrics section when using Segment by. [Line Chart] 3. Ratio format: Since your YoY metric is a ratio (division minus 1), make sure the metric format is set to percentage (e.g.,
##.##%
) so it displays correctly. 👍 0 button 👎 0 button â„šī¸ Tip: Mention @kapa.ai in the thread for follow-ups. 👀 Our Support team monitors all messages and will jump in if needed.
j
Hi Cathy, if you are still facing issues please send us a direct link to the report and we csan look into it for you and provide a more hands on approach