Below is one I came up with, but the bottom text is using the sum offertory to subtract from the selected year instead of using the previous year. eg when I click 2024 on the category selector I want the indicator to show the sum offertory of year 2024 and the +ve or -ve change from the previous year
// Calculate the difference between the current and previous year
var currentYearTotal = $datapoint["SUM_Yearly_Offertory"];
var previousYearTotal = $reference["SUM_Yearly_Offertory"];
var difference = currentYearTotal - previousYearTotal;
// Calculate absolute difference and percent change
var absoluteDifference = Abs(difference);
var percentChange = IIf(previousYearTotal == 0, 0, (difference / previousYearTotal) * 100);
// Set default text color and symbol
var bottomTextColor = "black";
var bottomTextSymbol = "";
// Determine if the change is positive or negative
if (difference > 0) {
bottomTextColor = "green"; // Positive growth
bottomTextSymbol = "▲";
} else if (difference < 0) {
bottomTextColor = "red"; // Negative growth
bottomTextSymbol = "▼";
}
// Return formatted text for the Indicator widget
return {
middleText: "Ksh " + Text(currentYearTotal, "#,###"), // Display current year total
middleTextColor: "black",
middleTextMaxSize: "large",
bottomText: bottomTextSymbol + " " + Text(absoluteDifference, "#,###") +
" (" + Round(percentChange, 2) + "% Change)",
bottomTextColor: bottomTextColor,
bottomTextMaxSize: "medium"
};