IF Formula OR + AND

gazmoz17

Board Regular
Joined
Sep 18, 2020
Messages
158
Office Version
  1. 365
Platform
  1. Windows
Hi, been trying this for hours!!

Can you write OR then AND or do you write it AND then OR. The logic to me in this instance to return correct val would be OR then AND.

Trying Translate Sage (Accountancy software) syntax into excel IF formula so can pull it direct via a query instead of exporting from Sage. Report and IF forumlas work in Sage.

Sage (working expression) ;green



“?” Then

“:” Else



INVOICE_ITEM.UNIT_OF_SALE="EA" OR INVOICE_ITEM.UNIT_OF_SALE="EACH" OR INVOICE_ITEM.UNIT_OF_SALE="Each"OR INVOICE_ITEM.UNIT_OF_SALE="EA"OR INVOICE_ITEM.UNIT_OF_SALE="EA"OR INVOICE_ITEM.UNIT_OF_SALE="ea"?INVOICE_ITEM.QUANTITY:
STOCK.STOCK_CODE="4116" OR STOCK.STOCK_CODE="4117"?INVOICE_ITEM.QUANTITY/STOCK.UNIT_WEIGHT:INVOICE_ITEM.UNIT_OF_SALE="KG"OR INVOICE_ITEM.UNIT_OF_SALE="Kg" OR INVOICE_ITEM.UNIT_OF_SALE="kg" AND STOCK.UNIT_WEIGHT="0.000"? INVOICE_ITEM.QUANTITY/30:INVOICE_ITEM.QUANTITY/STOCK.UNIT_WEIGHT




Broke it down into sections (then tested formula works for section before combining overall).

*Cant get section 3 to work?....the AND OR combined.

Blue = excel.



1. INVOICE_ITEM.UNIT_OF_SALE="EA" OR INVOICE_ITEM.UNIT_OF_SALE="EACH" OR INVOICE_ITEM.UNIT_OF_SALE="Each"OR INVOICE_ITEM.UNIT_OF_SALE="EA"OR INVOICE_ITEM.UNIT_OF_SALE="EA"OR INVOICE_ITEM.UNIT_OF_SALE="ea"?INVOICE_ITEM.QUANTITY

Excel Formula:
=IF(OR(INVOICE_ITEM.UNIT_OF_SALE="EA",INVOICE_ITEM.UNIT_OF_SALE="ea",INVOICE_ITEM.UNIT_OF_SALE="Ea",INVOICE_ITEM.UNIT_OF_SALE="each",INVOICE_ITEM.UNIT_OF_SALE="EACH",INVOICE_ITEM.UNIT_OF_SALE="Each"), INVOICE_ITEM.QUANTITY,"")

2. :STOCK.STOCK_CODE="4116" OR STOCK.STOCK_CODE="4117"?INVOICE_ITEM.QUANTITY/STOCK.UNIT_WEIGHT:


Excel Formula:
=IF(OR(STOCK.STOCK_CODE="4116",STOCK.STOCK_CODE="4117"),(INVOICE_ITEM.QUANTITY*STOCK.UNIT_WEIGHT),"")

3. INVOICE_ITEM.UNIT_OF_SALE="KG"OR INVOICE_ITEM.UNIT_OF_SALE="Kg" OR INVOICE_ITEM.UNIT_OF_SALE="kg" AND STOCK.UNIT_WEIGHT="0.000"? INVOICE_ITEM.QUANTITY/30:

Excel Formula:
INVOICE_ITEM.UNIT_OF_SALE="KG"OR INVOICE_ITEM.UNIT_OF_SALE="Kg" OR INVOICE_ITEM.UNIT_OF_SALE="kg" AND STOCK.UNIT_WEIGHT="0.000"? INVOICE_ITEM.QUANTITY/30
=IF(AND([@[UNIT_WEIGHT]]="0",OR([@[UNIT_OF_SALE]]="KG",[@[UNIT_OF_SALE]]="kg",[@[UNIT_OF_SALE]]="Kg",[@[UNIT_OF_SALE]]="kG")), [@QUANTITY]/30, "")

; not returning

4. INVOICE_ITEM.QUANTITY/STOCK.UNIT_WEIGHT


(The fields in my table are diff to the data fields in sage but I’ve just matched them (find/replace for understanding….if anyone is willing to help ?) Will prob need help combining all sections as well if possible!



Many Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
It would be easier to help if you translated what the Sage means into English. But your tests of OR for different character cases is not necessary in Excel:
Book1 (version 2).xlsb
AB
1StringTEST KG
2kgTRUE
3KgTRUE
4KGTRUE
5kGTRUE
Sheet11
Cell Formulas
RangeFormula
B2:B5B2=A2="KG"
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top