Docs / Learn mapping / Mapper Comparisons
Compare text and numbers in X12 Mapper
Choose the comparison that matches the business value you are checking. A unit code may need a match that ignores letter case, while a unit price usually needs numeric equality.
Compare text with %== and %!=
%== compares text for equality while ignoring letter case. %!= checks that the text differs while ignoring letter case.
Both operators convert their operands to string representations before comparing. A numeric operand is accepted through that conversion: the number 2 becomes the text "2". The operation remains a text comparison. It does not normalize decimal formatting, so "12.50" and "12.5" differ.
These rules apply whether the value comes from a literal, variable, element, or function result. They apply in arrow filters and ordinary conditions, including loop filters.
Choose text or numeric equality in an arrow filter
This 850 contains one order line. Its line number is 1, quantity is 2, unit code is EA, and unit price is 12.50.
Open the Mapper workspace, choose Explore the demo on my own if prompted, and open salesOrder.map. In the Run pane, replace X12 input with the complete sample below. Keep the spaces in ISA.
ISA*00* *00* *ZZ*MODERNEDI *ZZ*WORKSPACEDEST *260413*1200*U*00401*000000001*0*T*>~
GS*PO*MODERNEDI*WORKSPACEDEST*20260413*1200*1*X*004010~
ST*850*0001~
BEG*00*SA*PO0001**20260413~
PO1*1*2*EA*12.50**UP*000000002011~
CTT*001~
SE*5*0001~
GE*1*1~
IEA*1*000000001~
Replace the map source with the whole block below and choose Run map. Each filter prints its label and the matching line number. firstNonEmpty supplies no match for an empty selection.
println("Unit text matches ea = " + firstNonEmpty(ST->PO1[03 %== "ea"](01), "no match"))
println("Quantity text matches 2 = " + firstNonEmpty(ST->PO1[02 %== 2](01), "no match"))
println("Price text matches 12.50 = " + firstNonEmpty(ST->PO1[04 %== 12.50](01), "no match"))
println("Price text matches 12.5 = " + firstNonEmpty(ST->PO1[04 %== 12.5](01), "no match"))
println("Price text differs from 12.5 = " + firstNonEmpty(ST->PO1[04 %!= 12.5](01), "no match"))
println("Price equals 12.5 numerically = " + firstNonEmpty(ST->PO1[04 == 12.5](01), "no match"))
Expected output
Unit text matches ea = 1
Quantity text matches 2 = 1
Price text matches 12.50 = 1
Price text matches 12.5 = no match
Price text differs from 12.5 = 1
Price equals 12.5 numerically = 1
For arrow filters, == and != use numeric comparison when the right operand is a number. Use a quoted string for an exact, case-sensitive text comparison, such as ST->PO1[03 == "EA"]. Use %== or %!= when comparing text while ignoring letter case.
If a populated field cannot be converted to a number, numeric == is false and != is true. For example, with PO103 = "EA", ST->PO1[03 != 2] includes the line. An empty field satisfies neither numeric == nor numeric !=; use isEmpty to check for missing data. Relational comparisons with nonnumeric text still report E2503 in arrow filters.
If price formatting should not affect equality, use numeric ==. If a text code's spelling matters, compare its text. The choice of operator determines the comparison; a numeric operand does not give case-insensitive comparison a numeric meaning.
Use the same text rule in conditions
This loop also prints 1 for the example line:
amount=12.50
forEach(line in ST->PO1 : line(04) %== amount) {
print(line(01))
}
Changing amount to 12.5 makes the text comparison fail. To match numerically equal prices regardless of those decimal zeros, use == instead.
Keep element formatting when extracting a value
Extracting a numeric element with find or a list index preserves its original text while retaining its numeric value. Given CTT*001~, both find(n in ST->CTT(01)) and ST->CTT(01)[0] print 001. Their numeric comparison with 1 succeeds; a text comparison with "1" differs from one with "001". Converting them to JSON still produces numeric 1.
Check the result on your sample
For optional data, null == null is true and null differs from text, zero, false, and empty selections. The text operators still render values as text, so null %== "NULL" is true. See typed values and explicit absence for JSON and fallback examples.
Try the filter on your own X12 samples. Save representative formatting and capitalization variations as mapping test cases to preserve the intended behavior. The Mapper Built-ins reference covers functions you can use to prepare comparison values.