IIF statement help

craig198101

New Member
Joined
Mar 16, 2016
Messages
5
Hi all,

I am trying to create a query to append records into a an existing table. I need the query to include the following IIF statement:
IF “REMAINING QTY” is less than Oracle FIFO “TxnQty”
THEN
1. Copy original Oracle FIFO record to INSERT brand new Oracle FIFO record with “TxnQty” = “TxnQty” - “REMAINING QTY” and “StatusCode” = ‘D’
2. UPDATE original Oracle FIFO “TxnQty” = “REMAINING QTY”, leaving “StatusCode” = ‘N’
END IF

Tables:
FIFOCMSData holds TxnQty and StatusCode
QTYFIFOWH holds REMAINING QTY and TxnQty1

I have managed to do part one with two IIF:
1.TxnQty: IIf([SumOfREMAINING QTY]<[TxnQty1],[TxnQty1]-[SumOfREMAINING QTY],"0")
2.StatusCode: IIf([SumOfREMAINING QTY]<[TxnQty1],"D","N")

Any ideas how to either do one nested iif(with example) or best way to create the above would be a massive help.

Big thank you in advance
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi,
what are the primary keys in the tables? It will be hard to write any queries without that information.
 
Upvote 0
Thank you for the reply the primary keys are FIFOCMSData: ReceiptSupplement(invoice number) and QTYFIFOWH: Invoice Number
 
Upvote 0
Hmm. Actually it can't be done because you want to copy a record:
1. Copy original Oracle FIFO record to INSERT brand new Oracle FIFO record with “TxnQty” = “TxnQty” - “REMAINING QTY” and “StatusCode” = ‘D’

But if you do that you will be copying the primary key as part of the new record. And you cannot have two records with the same primary key.
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

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