Page 1 of 1

Math Expressions With Metadata

Posted: Fri Jun 16, 2023 8:51 pm
by rgpepper
Trying to do this calculation that involves 2 pieces of metadata, as part of a multi-line with variables, for an email body. I can't seem to find the right formatting. I either get nothing but "Shortage % %", or I get the entire formula exactly as it is below. How do I format those 2 pieces of metadata to be resolved as numbers, in an equation?

Shortage %: [Switch.Calculation:Expression="((1-(["Metadata.TextIndexed:Path="/field-list/field[tag='Quantity Good']/value",Dataset="Submit",Model="XML"]/["Metadata.TextIndexed:Path="/field-list/field[tag='Quantity Ordered']/value",Dataset="Submit",Model="XML"]))*100)"] %

Re: Math Expressions With Metadata

Posted: Sat Jun 17, 2023 9:29 am
by jan_suhr
Your calculation formula worked for me, but I used PrivateData for the values since it was easier to set up for testing.

I see that you have the Metadata as TextIndexed try instead with just Text

Re: Math Expressions With Metadata

Posted: Sun Jun 18, 2023 8:32 pm
by tdeschampsBluewest
[Switch.Calculation:Expression="((1-(["Metadata.TextIndexed:Path="/field-list/field[tag='Quantity Good']/value",Dataset="Submit",Model="XML"]/["Metadata.TextIndexed:Path="/field-list/field[tag='Quantity Ordered']/value",Dataset="Submit",Model="XML"]))*100)"]

Code: Select all

[Switch.Calculation:Expression="
	(
		(
			1-(
				["Metadata.TextIndexed:Path="/field-list/field[tag='Quantity Good']/value",Dataset="Submit",Model="XML"]
				/["Metadata.TextIndexed:Path="/field-list/field[tag='Quantity Ordered']/value",Dataset="Submit",Model="XML"]
			)
		)
		*100
	)
"]
The only way it could fail, is if ["Metadata.TextIndexed:Path="/field-list/field[tag='Quantity Ordered']/value",Dataset="Submit",Model="XML"] is equal to 0 or null.