if(value1>value2)
output=value1;
else
output=value2;
(5–string–length(value1>value2))*value1+(5–string–length(value1<=value2))*value2
If the first string length will be 4 for "true" and 5 – 4 = 1, the first multiplication returns value1. If the second string length will be 5 for "false" and 5 – 5 = 0, the second multiplication will return value2.
Conditional logic in action
I applied this approach to the production form mentioned above. Employees would enter their hourly production and the latest hour’s data would be promoted to a promoted field for SharePoint reporting.
The code ended up like this:
../my:goodParts16+(string–length(../my:goodParts16>0or../my:badParts16>0)–4)*(../my:goodParts15+(string–length(../my:goodParts15>0or../my:badParts15>0)–4)*(../my:goodParts14+(string–length(../my:goodParts14>0or../my:badParts14>0)–4)*(../my:goodParts13+(string–length(../my:goodParts13>0or../my:badParts13>0)–4)*(../my:goodParts12+(string–length(../my:goodParts12>0or../my:badParts12>0)–4)*(../my:goodParts11+(string–length(../my:goodParts11>0or../my:badParts11>0)–4)*(../my:goodParts10+(string–length(../my:goodParts10>0or../my:badParts10>0)–4)*(../my:goodParts9+(string–length(../my:goodParts9>0or../my:badParts9>0)–4))))))))
As can be seen, the code piles up quickly but it works. If the user has entered data for the 4:00pm hour, that branch will show. Otherwise, it will check for 3:00pm, then 2:00pm, etc.
Attached is an example InfoPath form template demonstrating this approach. After downloading the file, remove the ".rename" extension from its name.
- InfoPath form template with conditional logic
SIr, I doff my hat to you. This got me out of a heap of trouble. Was able to implement a bitwise flag using this technique. So thank you.