Category / Section
How to Display Percentage Difference Between the Current and Previous Year in Chart Widget
Published:
This article will guide you on how to display the percentage difference between the current year and the previous year in a chart widget using expressions.
Steps to Display Percentage Difference:
- Create expressions for the current year and the previous year: You need to create an expression for the measured field for the current year and the previous year. Use the following expressions:
Current Year: `IF(YEAR([Date_Column])= Current_Year, [Column], 0)`
Previous Year: `IF(YEAR([Date_Column])= Previous_Year, [Column], 0)`
- Create an expression to calculate the percentage difference: Use the following expression to calculate the percentage of difference:
Percentage Difference: `((SUM([Previous Year]) - SUM([Current Year])) / ((SUM([Current Year]) + SUM([Previous Year])) / 2)) * 100`
- Bind the expression fields to the chart widget: Bind the "Percentage of Difference" expression field to the Value(s) section and the "Current Year" and "Previous Year" expression fields to the Tooltip section.
- Render the chart widget: The chart widget will now display the percentage difference between the current year and the previous year.
By following these steps, you can successfully display the percentage difference between the current year and the previous year in a chart widget.