Forum Discussion
mandyturcotte
Sep 20, 2022Copper Contributor
Using FIFO to Determine Sale Price of Fuel
In our business, we purchase fuel in bulk and it is then "sold" to our equipment at cost. I need to be able to attribute a price to each sale. I keep feeling like I've almost got it and then it ...
- Sep 20, 2022
Now the formula with a mixed price.
PeterBartholomew1
Sep 21, 2022Silver Contributor
That is a surprise to me. It would not have been any surprise had you not had access to Excel 365, most users do not realise just how profound the changes since 2018 have been. My belief is that even with a semi-annual license you should have had access to the Lambda helper functions for a while now. Do you control the update cycle, or do you need to go to corporate IT?
SergeiBaklan Can you advise?
Just in case you can gain access to SCAN and MAP, I have tried to repackage the solution as a Lambda function to facilitate reuse, hopefully for you, but otherwise for anyone else with FIFO based challenges.
Sorksheet formula
= CostFIFOλ(quantitySold, purchaseQuantity, purchasePrice)
CostFIFOλ
= LAMBDA(outputQuantity,inputQuantity,inputCost,
LET(
Addλ, LAMBDA(x, y, x + y),
cumInput, SCAN(0, inputQuantity, Addλ),
cumOutput, SCAN(0, outputQuantity, Addλ),
MAP(cumOutput-outputQuantity, cumOutput,
LAMBDA(u₀,u₁,
SUM(
MAP(cumInput-inputQuantity, cumInput, inputCost,
LAMBDA(v₀,v₁,w,
MAX(MIN(v₁,u₁) - MAX(v₀,u₀), 0) * w
)
)
) / (u₁-u₀)
)
)
)
);
mandyturcotte
Sep 21, 2022Copper Contributor
Thanks! I'll keep this bookmarked and come back to it when I can figure out access. I'll have to talk to our IT Team.