Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

paulyeo11
Valued Contributor II

SET expression after change to IF expression give wrong result

Hi All


Below expression work fine :-

Sum(Aggr(SUM({<year = {'$(=Max(year))'}, month = {"<=$(=IF(GetSelectedCount(month), Max({<year = {'$(=Max(year))'}>}month), Num(Month(Today()))))"}>}sales/1), GROUP_TYPE))


when I change the above expression to below , it return wrong result.

Sum(if(Year_n<'2',sales/Rate,GROUP_TYPE))


May i know where go wrong ?


Paul


3 Replies
prma7799
Honored Contributor III

Re: SET expression after change to IF expression give wrong result

Try this

Sum(if(Year_n<'2',(Sum(sales) / avg(Rate)),GROUP_TYPE))


or


Sum(if(Year_n<'2',(Sum(sales) / Sum(Rate)),GROUP_TYPE))

paulyeo11
Valued Contributor II

Re: SET expression after change to IF expression give wrong result

Hi Sir


Enclosed Table 1 using SET expression , the result correct.


I try using your suggest expression on IF not working.


Paul Yeo

prma7799
Honored Contributor III

Re: SET expression after change to IF expression give wrong result

Try this

=if(Year_n<'2',(Sum(sales) / avg(Rate)), (GROUP_TYPE))

Community Browser