gianfranco-campana-vs opened a new issue, #45888:
URL: https://github.com/apache/superset/issues/45888
### Bug description
<html>
<body>
<!--StartFragment--><p data-pm-slice="1 3 []"><span>When using the
</span><strong><span>Big Number with Trendline</span></strong><span>
visualization with a temporal X-axis and </span><strong><span>Aggregation
Method = Last Value</span></strong><span>, the displayed main value does not
necessarily correspond to the most recent timestamp in the time
series.</span></p><p><span>It appears that Superset may use the last data point
returned by the database query, rather than identifying the data point with the
greatest timestamp.</span></p><p><span>This can lead to incorrect results when
the database does not return grouped time-series data in chronological
order.</span></p><h2><span>Configuration</span></h2><ul
data-spread="false"><li><p><span>Visualization: Big Number with
Trendline</span></p></li><li><p><span>Temporal X-axis: </span><code
dir="ltr"><span>timestamp</span></code></p></li><li><p><span>Time Grain:
Minute</span></p></li><li><p><span>Aggregation Method: Last Value</span><
/p></li><li><p><span>Metric: </span><code
dir="ltr"><span>row_count</span></code></p></li><li><p><span>Show Timestamp:
Enabled</span></p></li><li><p><span>Show Trend Line:
Enabled</span></p></li><li><p><span>Database:
ClickHouse</span></p></li></ul><h2><span>Generated SQL</span></h2><pre><code
class="language-sql"><span>SELECT
dateTrunc('MINUTE', toDateTime("timestamp")) AS "timestamp",
sum(DISTINCT (
cityHash64(table_name) + row_count
) - cityHash64(table_name)) AS "row_count"
FROM "database_name"."table_name"
WHERE
"table_name" IN ('example')
GROUP BY
"timestamp"
LIMIT 50000</span></code></pre><p><span>The generated query does not include
an </span><code dir="ltr"><span>ORDER BY</span></code><span>
clause.</span></p><h2><span>Observed behavior</span></h2><p><span>The Big
Number displays </span><strong><span>631M</span></strong><span>, which is
incorrect.</span></p><p><span>The latest available timestamp is </span><code
dir="ltr"><span>2026-10-30 11:00:00</span></code><span>, and its corresponding
value is
</span><strong><span>289,712,073</span></strong><span>.</span></p><p><span>When
executing the same query with:</span></p><pre><code
class="language-sql"><span>ORDER BY "timestamp"
DESC</span></code></pre><p><span>the first result is:</span></p>
timestamp | row_count
-- | --
2026-10-30 11:00:00 | 289712073
<p><span>Therefore, the main Big Number displays approximately
</span><strong><span>631 million</span></strong><span> instead of the expected
</span><strong><span>289,712,073</span></strong><span>.</span></p><p><span>The
trendline itself displays the historical data points, but the main value does
not correspond to the latest timestamp.</span></p><h2><span>Expected
behavior</span></h2><p><span>When </span><strong><span>Aggregation Method =
Last Value</span></strong><span> is selected, the main Big Number should
display the metric value associated with the greatest timestamp in the time
series, regardless of the order in which the database returns the grouped
rows.</span></p><p><span>Superset should ensure that the time-series data is
chronologically ordered before applying the </span><code dir="ltr"><span>Last
Value</span></code><span> aggregation, rather than relying on the database
result order.</span></p><p><span>The displayed timestamp, when enabled, should
also correspond to
the timestamp associated with that latest
value.</span></p><h2><span>Additional information</span></h2><p><span>Adding
</span><code dir="ltr"><span>ORDER BY timestamp DESC</span></code><span> to the
SQL query changes the result, suggesting that the current implementation may
depend on the order of the returned rows.</span></p><p><span>This issue is
particularly relevant for databases such as ClickHouse, which do not guarantee
the order of grouped query results unless an explicit </span><code
dir="ltr"><span>ORDER BY</span></code><span> is
specified.</span></p><h2><span>Environment</span></h2><ul
data-spread="false"><li><p><span>Apache Superset version: </span><code
dir="ltr"><span>0.0.0-dev</span></code></p></li><li><p><span>Build: Development
build</span></p></li><li><p><span>Database:
ClickHouse</span></p></li></ul><!--EndFragment-->
</body>
</html>
### Screenshots/recordings
_No response_
### Superset version
master / latest-dev
### Python version
I don't know
### Node version
I don't know
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [ ] I have searched Superset docs and Slack and didn't find a solution to
my problem.
- [ ] I have searched the GitHub issue tracker and didn't find a similar bug
report.
- [ ] I have checked Superset's logs for errors and if I found a relevant
Python stacktrace, I included it here as text in the "additional context"
section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]