Highlighted
Occasional Contributor

IF list item 'x' THEN 'do this' ELSE...

I am trying to do an IF statement within a module dimensionalised by a List ('Volumes') which has 2 members: Retails and Wholesales.

 

I need to do a particular calculation depending on if the 'Volumes' are Retails or Wholesales.

 

I have tried IF Volumes.Retails THEN x ELSE y but this not work, giving the following error message:

 

The formula for 'XP 05 Derivative Mix'.Mix is invalid:
First argument for 'IF' function must have BOOLEAN format not LIST:Volumes

 

Can anyone help / advise?

 

 

Thanks

6 REPLIES 6
Highlighted
Master Anaplanner/Community Boss

Re: IF list item 'x' THEN 'do this' ELSE...

Hi Ricardo,

 

Formula Correction, try this

 

IF ITEM('Volumes')=Volumes.Retails THEN X ELSE Y

 

~Vignesh M

Highlighted
Occasional Contributor

Re: IF list item 'x' THEN 'do this' ELSE...

Super, thanks for the quick reply!
Highlighted
Master Anaplanner/Community Boss

Re: IF list item 'x' THEN 'do this' ELSE...

Hi @Riccardo @VIGNESH.M 

 

For best practice (Refer to 2.02-12 of Planual), please avoid hardcoding of list member, and do the following instead

Screen Shot 2020-01-06 at 10.36.22.png

 

Thanks,

LipChean

Highlighted
Master Anaplanner/Community Boss

Re: IF list item 'x' THEN 'do this' ELSE...

Hi @LipChean_Soh @ArunManickam ,

 

I totally agree with you, we should not do the hardcoding like this and instead use the system module as mentioned in Planula for the best practices.

 

Thanks,

Vignesh M

Highlighted
Occasional Contributor

Re: IF list item 'x' THEN 'do this' ELSE...

Thanks all, good points. This list is fixed and so hardcoding should not be an issue, but noted your points on best practice.
Highlighted
Community Boss

Re: IF list item 'x' THEN 'do this' ELSE...

Hi @Riccardo 

 

 @VIGNESH.M  reply must work, but note that it is hardcoded. It is ok, if the list "Volumes" is fixed and does not change with time. If not,

 

Please create a system module for Volumes (SYS VOLUMES) and keep your boolean line item there (RETAIL & WHOLESALE). Manually maintainted by the administrator.

 

If 'SYS VOLUMES'.RETAIL then <<formula for RETAIL>> else if 'SYS VOLUMES'.WHOLESALE then <<formula for WHOLESALE>> else <<so on>>

 

There are ways to minimize the nested IFs as well.

 

Thanks
Arun