Group by date with aggr and apply sub aggr with group by date in elastic search

How to implement below C# entity logic in Elasticsearch

var queryable1 = queryable.GroupBy(g => g.Date).Select(x => new GroupChartDto() 
{
 DailyPnL = x.Sum(s => s.DailyPnL), 
Date = x.Key, 
AggregateSum = queryable.Where(w => w.Date.Date <= x.Key.Date).Sum(s => s.DailyPnL) }).ToList();

I have applied query

{ "query":{ "bool": { "filter": [ {"terms": {"account": ["abc","xyz","rs876909kk"]}}, {"range": {"date": {"gte": "2021-07-12","lt": "2022-07-12"}}} ] } }, "aggs": { "group_by_month": { "date_histogram": { "field": "date", "calendar_interval": "month", "format": "yyyy-MM-dd" }, "sum_dailyPnL":{ "filter": {"range": {"date": {"lt": "group_by_month.key_as_string"}}}, "aggs": {"sum_dailyPnL": { "sum": { "field": "dailyPnL" } }} } } } }