Math Expressions With Metadata

Post Reply
rgpepper
Member
Posts: 80
Joined: Wed Oct 14, 2015 2:09 am

Math Expressions With Metadata

Post 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)"] %
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Math Expressions With Metadata

Post 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
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
tdeschampsBluewest
Member
Posts: 37
Joined: Tue Jun 01, 2021 11:57 am

Re: Math Expressions With Metadata

Post 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.
Post Reply