Writing If clause with multiple and conditions

Hi Team,

We have requirement to check multiple conditions before assigning a value. I have written statement as below but it’s not working as expected. Please let me how can I improve this.

IF (asText({Amount Type})=‘Amount’ and asnumber(left({Natural Account},1)) >= 6 and asnumber({Profit Center}) > 0) THEN padstart(asText({Profit Center}),‘0’,4) ELSE asText(“0000”)

Thanks,
Mahantesh

Hi Mahantesh,

when you say “it’s not working as expected” what exactly is expected? Also, on what values exactly the expression doesn’t work as expected?

Hello,

The supplied values are as below,
Amount Type is ‘Amount’
Natural Account is 61310000
Profit center is 7253
I am expecting profit center value to be returned but it’s not returning anything(even not ‘0000’).
I am doubting on whether the syntax of the expression is correct? Can we use ‘and’ keyword to add multiple conditions in IF statement?

Thanks,
Mahantesh

Thank you for the clarification. I can't reproduce the problem (see below). What am I missing?

expression.morph (1.9 KB)

Yes, you can use AND, OR, and NOT in conditions.