If you are unable to create a new account, please email support@bspsoftware.com

 

Is it possible to use an 'if' statement when calculating a value?

Started by gordread, 03 Sep 2014 03:37:26 PM

Previous topic - Next topic

gordread

I'm pretty new to framework manager, so I have a pretty basic question, and I haven't been able to find a clear answer, so hopefully someone here can help.

I am trying to create a calculated value (PreviousRun) using the following logic:

if ([Calculated_Values].[TodayDayOfWeek]  = 1 ) then
   (PreviousRun = _add_days(current_date, -2))
else
   (PreviousRun = _add_days(current_date,-1))

Basically if 'TodayDayOfWeek' is Monday, then set the value to 2 days ago, otherwise, set the value one day ago.

My question: is this even possible?  If so, what is the syntax?  If not, any suggestions?

Thanks,

Gordon

MFGF

Quote from: gordread on 03 Sep 2014 03:37:26 PM
I'm pretty new to framework manager, so I have a pretty basic question, and I haven't been able to find a clear answer, so hopefully someone here can help.

I am trying to create a calculated value (PreviousRun) using the following logic:

if ([Calculated_Values].[TodayDayOfWeek]  = 1 ) then
   (PreviousRun = _add_days(current_date, -2))
else
   (PreviousRun = _add_days(current_date,-1))

Basically if 'TodayDayOfWeek' is Monday, then set the value to 2 days ago, otherwise, set the value one day ago.

My question: is this even possible?  If so, what is the syntax?  If not, any suggestions?

Thanks,

Gordon

Hi Gordon,

You're almost there! You just need to realise that the expression itself controls the value returned by the calculated item, so the 'PreviousRun =' parts are not required - that part is inherent.

Try this:

if ([Calculated_Values].[TodayDayOfWeek]  = 1 ) then
   (_add_days(current_date, -2))
else
   (_add_days(current_date,-1))

Cheers!

MF.
Meep!

gordread

So close. :)  As soon as I took out the assignment it worked just fine.

Thanks MF.

Gordon