$date1=20210208 $date2=20210712
ds1:select month,target from table where month between '${date1}' and '${date2}' order by month
目标汇总单元格=
sum(maparray(ds1.select(target),
if(index=1,
item/DAYSOFMONTH(todate($date1,"yyyyMMdd"))*(DAYSOFMONTH(todate($date1,"yyyyMMdd"))-right($date1,2)+1),
if(index=count(ds1.select(target)),item/DAYSOFMONTH(todate($date2,"yyyyMMdd"))*right($date2,2)
,item))
))
或者直接在SQL里处理
select month,
case when month='${left(date1,4)}' then target/${DAYSOFMONTH(todate(date1,"yyyyMMdd"))}*${DAYSOFMONTH(todate(date1,"yyyyMMdd"))-right(date1,2)+1}
when month='${left(date2,4)}' then target/${DAYSOFMONTH(todate(date2,"yyyyMMdd"))}*${right(date2,2)-0}
else target end as 目标
from table
where month between '${date1}' and '${date2}'
order by month