cancel
Showing results for 
Search instead for 
Did you mean: 

IIF condition in Allocation Method

SRAI
New Contributor III

Hi,

I am trying to evaluate an IIF condition in Allocation Method. If |dIdleDate| is '1/1/1900' AND |dIdleDate| < |DCode4| then Run a rule (with parameters) Else run a rule (with different parameters).

Code is as below:

IIF( |dIdleDate| = '1/1/1900' && |dIdleDate| < |DCode4|, 

      XFBR(ABC_TLP_ParamHelper, Test, StartDate=|DCode3|, EndDate=|dIdleDate|, CalcPer=|CalcPer|, SystemStartDate=|!SystemStartDate_TLP!|),

       XFBR(ABC_TLP_ParamHelper, Test, StartDate=|DCode3|, EndDate=|DCode4|, CalcPer=|CalcPer|, SystemStartDate=|!SystemStartDate_TLP!|)) )

but it runs the rule 2 times (for true condition and flase condition). 

Does IIF works like that? If above doesnt work then I will have to handle it in the rule. Thanks.

 

Regards,
Sid

1 ACCEPTED SOLUTION

MarcR
VIP

Appologies Sid, i was writing this from my phone at breakfast 😉

If you want a nested function inside an XFBR this is true. So a parameter for an XFBR is actually an XFBR itself:

XFBR(BR, Function, parameter=[XFBR(Rule, function, parameter={parameter}])

But for an IIF statement that is not the case, you can just write the statement like you initially did. your issue is probably in the &&, try to replace that with AND, otherwise check your parameters by starting with IIF(1=1, xfbr, xfbr) or return the contents of your values in an allocation method so you are sure what comes out (the |dldleDate| looks a bit strange to me but that can be the formatting of the community.).

Marc Roest
OneStream consultant @Finext

View solution in original post

8 REPLIES 8

MarcR
VIP

Hi Sid, that is possible, for the nested function you should replace the ( with [ and ) with ]. If you have [] brackets in your nested function, these should be replaced by {} brackets. In this way OneStream understands what is the nested function.

Marc Roest
OneStream consultant @Finext

SRAI
New Contributor III

Thanks Marc.

So my function will look like below?

IIF( |dIdleDate| = '1/1/1900' && |dIdleDate| < |DCode4|,

XFBR[ABC_TLP_ParamHelper, Test, StartDate=|DCode3|, EndDate=|dIdleDate|, CalcPer=|CalcPer|, SystemStartDate=|!SystemStartDate_TLP!|],

XFBR[ABC_TLP_ParamHelper, Test, StartDate=|DCode3|, EndDate=|DCode4|, CalcPer=|CalcPer|, SystemStartDate=|!SystemStartDate_TLP!|])

MarcR
VIP

Appologies Sid, i was writing this from my phone at breakfast 😉

If you want a nested function inside an XFBR this is true. So a parameter for an XFBR is actually an XFBR itself:

XFBR(BR, Function, parameter=[XFBR(Rule, function, parameter={parameter}])

But for an IIF statement that is not the case, you can just write the statement like you initially did. your issue is probably in the &&, try to replace that with AND, otherwise check your parameters by starting with IIF(1=1, xfbr, xfbr) or return the contents of your values in an allocation method so you are sure what comes out (the |dldleDate| looks a bit strange to me but that can be the formatting of the community.).

Marc Roest
OneStream consultant @Finext

SRAI
New Contributor III

Thanks Marc. I ended up evaluating the condition in the rule rather than in Allocation method. Also, dIdleDate is variable defined for IdleDate in Thing Planning.

 

Cheers

Sid

SRAI
New Contributor III

Hi Marc,

The last resort is to evaluate in nested XFBR condition (logic) in Main rule. But, I am still trying to work out how we can pass an XFBR as a parameter inside another XFBR (in Allocation Method). I tried lot of permutation combination but it doesn't work. Any idea how below will work.

XFBR(ABC_TLP_ParamHelper, Test, EndDate = XFBR(ABC_TLP_ParamHelper, PL_Ext, EndDate = |DCode4|, ExtDate = |dIdleDate|), ExtDate = |dIdleDate|)

 

Thanks.

MarcR
VIP

Just put square brackets around the inner XFBR [xfbr…(…)] that should do it. When you get an error message the error is often showing the before and after for your allocation method, there you can see which parameter/ variable was transformed correctly and which was not.

Marc Roest
OneStream consultant @Finext

SRAI
New Contributor III

Hi Marc,

It cannot resolve inner XFBR.

SRAI_4-1656482648749.png

 

When I print, EndDate in Test function this is what I get in log:

SRAI_3-1656482545555.png

 

 

 

 

 

Hi Sid, see below a working example, perhaps you can use this as a reference:

XFBR(BusinessRule, Function, RegID=|RegisterID|, RegInstance=|RegisterIDInstance|, StartDate=|dtStartDate|, EndDate=[XFBR(TCR_ExtParamHelper, GetSumCustom, RegID=|RegisterID|, Criteria={Account='AccountName' AND Period=|CalcPer| AND RegisterID='|RegisterID|_|RegisterIDInstance|'}, Field=Amount)], IBR=[XFBR(TCR_ExtParamHelper, GetSumCustom, RegID=|RegisterID|, Criteria={Account='AccountName2' AND Period=|CalcPer| AND RegisterID='|RegisterID|_|RegisterIDInstance|'}, Field=Amount)])
Marc Roest
OneStream consultant @Finext
Please sign in! SRAI