Keep latest utility meter sensor data for a cycle and delete the rest

Hi,
I have utility meters (through the interface) that tracks ie. cost and kWh over a period of time for many devices. Because of the slow speed of the graph (custom:apexcharts-card) I want to delete all sensor history BUT keep the last (or max) sensor data for every cycle (day, month, year etc).

Is this possible?

With kind regards,
Steinar