If and AND expression issue

HI,

I have a field in which I want to perform calculations based on product type so I have written a formula in auto compute as follows :

IF(AND([Choose one of the following]= Mosquito Net,(([Product Cost (Mosquito Net)]*[No. of Mosquito Nets]) + [Installation Cost(Mosquito Net)]))),
IF(AND([Choose one of the following] = Curtain,IF([IS lead weight required] = YES,[Product Total (Curtain)] + [Cost of Stitching] + [Lining Amount] + [Cost of Leadweight]+[Curtain Tape Cost]+[Backloop Tape cost],[Product Total (Curtain)] + [Cost of Stitching] + [Lining Amount]+[Curtain Tape Cost]+[Backloop Tape cost])))

Where in based on type of product choosen the formula needs to be applied but I am getting the following error:
Column Name โ€˜Total Amount (AB)โ€™ in Schema โ€˜Measurement Form_Schemaโ€™ of Column Type โ€˜Decimalโ€™ has an invalid app formula '=OR([Choose one of the following]= Mosquito Net,(([Product Cost (Mosquito Net)][No. of Mosquito Nets]) + [Installation Cost(Mosquito Net)])),([Choose one of the following] = Curtain,IF([IS lead weight required] = YES,[Product Total (Curtain)] + [Cost of Stitching] + [Lining Amount] + [Cost of Leadweight]+[Curtain Tape Cost]+[Backloop Tape cost],[Product Total (Curtain)] + [Cost of Stitching] + [Lining Amount]+[Curtain Tape Cost]+[Backloop Tape cost]))โ€™. Condition OR(([Choose one of the following] = โ€œMosquito Netโ€), (([Product Cost (Mosquito Net)][No. of Mosquito Nets])+[Installation Cost(Mosquito Net)])) has an invalid structure: subexpressions must be Yes/No conditions

I am unable to understand where I am going wrong if some guidance could be provide?

0 4 168
4 REPLIES 4

Try:

SWITCH([Choose one of the following],
	"Mosquito Net", (([Product Cost (Mosquito Net)]*[No. of Mosquito Nets]) + [Installation Cost(Mosquito Net)]),
	"Curtain", 
	(
			IF(
				[IS lead weight required] = YES,
				([Product Total (Curtain)] + [Cost of Stitching] + [Lining Amount] + [Cost of Leadweight]+[Curtain Tape Cost]+[Backloop Tape cost]),
				([Product Total (Curtain)] + [Cost of Stitching] + [Lining Amount]+[Curtain Tape Cost]+[Backloop Tape cost])
			)
	)
)

HI,

Thanks for the reply I am getting the following error :

SWITCH function is used incorrectly: Inputs to SWITCH() must be an initial expression, one or more value-result pairs, and a default result

Hi @Boa_Casa

You need to add something in the last input of SWITCH function.

So:

  • you have some values for โ€œmosquito netโ€,
  • other values for 'curtain"
  • and you need to add some default value at the end.

Please have a look to this article

Should be something like:

 SWITCH([Choose one of the following],
	"Mosquito Net", (([Product Cost (Mosquito Net)]*[No. of Mosquito Nets]) + [Installation Cost(Mosquito Net)]),
	"Curtain", 
	(
			IF(
				[IS lead weight required] = YES,
				([Product Total (Curtain)] + [Cost of Stitching] + [Lining Amount] + [Cost of Leadweight]+[Curtain Tape Cost]+[Backloop Tape cost]),
				([Product Total (Curtain)] + [Cost of Stitching] + [Lining Amount]+[Curtain Tape Cost]+[Backloop Tape cost])
			)
	),
   "default_Value"
)

If you have only two possible choices, you can either remove the โ€œcurtainโ€ line from the what @Heru just wrote, or use a IF(test, expressionIfYes, expressionIfNo) statement.

Hi,

Thanks a lot for this and it did resolve my issue.

Top Labels in this Space