Select to view content in your preferred language

compare integer fields with code block

141
3
2 weeks ago
itayroei
Emerging Contributor

hallo community.

i try to compare 2 field with number and want to know in every row if tha numbers equal or not

can i get here simple code block  to get this result?

regards

itay

 

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

you are missing the example and the code block you used

perhaps you could just create a simple integer field and use something like

def compare(a, b):
    """compare 2 fields and return 0 for different, 1 otherwise"""
    if a and b:
        val = 1 if a == b else 0
        return val
    return None

expression compare(!a!, !b!) where `a` and `b` are your field names enclosed in ! marks


... sort of retired...
0 Kudos
itayroei
Emerging Contributor

thank you Dan

it's really work 🙂

0 Kudos
DanPatterson
MVP Esteemed Contributor

good, 

perhaps you could go back and click Accept as Solution on my response


... sort of retired...
0 Kudos