How to get sum of distinct elements in a column of ElasticSearch on a Singlestat Panel?

Hello Everyone,

I am trying to calculate the sum of a variable in metric section grouped by date histogram. But my goal is to calculate the sum of all the distinct elements in that column.
Please help me how to get the distinct sum of variables using metric in ElasticSearch.

Regards and Thanks