Difference in Tag History Values Between Script and Excel Export

Thanks for the reply!

To clarify my setup: I’m using an XYChart to show active energy consumption, and I’m calling a script through an expression binding like this:
runScript("Medidor.Consumo_Diario.calcular_consumo_tag", 60000, {view.params.Path}+"/CT/WHP", {../Container_DateTime/DateTime_Inicio.props.formattedValue}, {../Container_DateTime/DateTime_Fim.props.formattedValue})

This script calculates daily consumption and separates it into “peak” and “off-peak” periods. Here's the full script I'm using:


The problem is that the values displayed in the chart differ from the values I see when I export the same tag using the tag browser’s “Export to Excel” function — especially in the off-peak values. I'm trying to understand why this happens.

Could this be due to how the script is calculating the consumption using the tag history for specific periods (e.g., 17h-20h for peak)? Or maybe some kind of interpolation difference between how the chart and the export handle historical data?

Any thoughts or suggestions on how to align these values would be super helpful. Thanks again!