永洪社区

标题: 计算环比的时候速度慢,有无优化方案? [打印本页]

作者: yhdata_laeU7hh2    时间: 2022-9-9 10:20
标题: 计算环比的时候速度慢,有无优化方案?
核心品类占比:


if(param['日期维度']=='2') then
//YTD
sum( if(col['年月' <=param['日期'
and col['年份' == year(param['日期') and col['战略品类']=='核心品类')
then  col['NSR' end)
/
sum( if(col['年月' <=param['日期'
and col['年份' == year(param['日期') )
  then  col['NSR' end)
  //MTD
else
sum(
if(col['年月' ==param['日期'and col['战略品类']=='核心品类' )
then col['NSR' end )
/
sum(
if(col['年月' ==param['日期' )
then col['NSR' end )

end




////////////////////////////////////////////////////////////////////////////


上月核心占比:

if(param['日期维度']=='2') then
//YTD
sum( if(col['年月' <=dateAdd( param['日期' ,'month',-1)
and col['战略品类']=='核心品类'
and col['年份' == year(param['日期')) then  col['NSR' end)
/
sum( if(col['年月' <=dateAdd( param['日期' ,'month',-1 )
and col['年份' == year(param['日期')) then  col['NSR' end)

//MTD
else
sum(if(col['年月' ==dateAdd( param['日期' ,'month',-1) )
  and col['战略品类']=='核心品类'
then col['NSR' end)
/
sum(if(col['年月' ==dateAdd( param['日期' ,'month',-1) )
then col['NSR' end)
end
/////////////////////////////////////////////////////////////
核心占比环比:
col['核心品类']- col['上月核心']





作者: yhdata_bear    时间: 2022-9-9 10:24
是数据量大吗?
作者: yhdata_laeU7hh2    时间: 2022-9-9 10:42
yhdata_bear 发表于 2022-9-9 10:24
是数据量大吗?

120万,不算大吧,在页面上这个字段有时候要四五秒才能出来
作者: yhdata_bear    时间: 2022-9-9 14:24
目前也只能减少一点数据量吧,清一清缓存,或者数据做抽样了





欢迎光临 永洪社区 (http://club.yonghongtech.com/) Powered by Discuz! X3.4