Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying the below expression. I want to use the greater than less in set analysis and I also need to apply num function over the modifier
sum({<Year={"=$(=Year(max(s_date)))"},Month = {"=num(Month)>=$(=Addmonth(max(s_date),-9)) <=$(=Addmonth(max(s_date),-1)) "}>} revenue)
Can someone please help me fix this syntax.
Regards
Shah
If you have a calendar with a month serial field, like this
load
d, // date
year(d) as y, // year
month(d) as m, // month
year(d)*12 + month(d) as mserial, // month serial
ceil(rand()*100) as revenue
;
load
date(makedate(2015) + iterno()-1) as d
AutoGenerate 1
While IterNo() <= 730;
you can use the expression
sum({$ <y=,m=,mserial={">=$(=max(mserial)-8)<=$(=max(mserial))"}>} revenue)
and that also works crossing years
Thanks for the solution. My problem is that I do not have access to the loading script or the data behind it so the only way for me to do is using the set analysis expression
Secondly It would be also good for me from learning perspective to see how we can do it inside set analysis
For example, I know how to use greater than less than in set analysis and I also know how to apply a function to a modifier by doing something for example Month = {"=Num(Month) <= 2"}
However, I dont know how to combine these two expressions so I will appeciate if someone can help me using set analysis
for revenue between max date - 9 months and max date
sum({$ <Year=,Month=,s_date={">=$(=addmonths(max(s_date),-9))<=$(=max(s_date))"}>} revenue)