• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

fifo sell excel macro

farhadbayaty

New Member
Greetings and Regards
Dear Friends
I have sold in the file that I have attached. In column "c" I have made a sale and in column "d" the settlement has been settled.
Now, I want to make a report through which I can understand how many days each customer has settled.
Like the first output from the first input (fifo)

Sorry if my writing is inappropriate.
Because I am from Iran

Thank you very much
 

Attachments

  • 20200407 new.xlsb
    25 KB · Views: 23
Salaam! I never knew that Excel could display columns from right to left like that! It caused me some confusion at first, but mostly now I'm just delighted at seeing something new.

That's a long, long formula in column G. I tried to break it into smaller pieces and understand it, but gave up after a while. Anyway, I think your question is about how to calculate column H.

But it isn't clear to me what you want to go in H. I see that you filled in some sample values, but I don't see the relationship between H and E/F. I do see that H2 and H3 are blank, probably because F2 and F3 are empty. But for the other rows, I can't see what's happening. Can you explain how you calculate H?

Khoda hafez :).
 
Hi :)
Thank you for your time

The answer I got is written in the "g" column, but the answer I want to get should be written "h".
Suppose a company has sales that fall into column "c"
Then, on different dates, the customer will settle the account
I put a note in cell "h6" that shows how to calculate it
But with my formula I come up with a different number (g6).
I think I should use an array formula. But I don't know how !!!
It is assumed that every settlement he makes is from the first sale.
Some settlements include two or more sales
Also, sometimes a sale may happen on a few dates.
Finally, I would like to conclude that it takes a few days for sales to settle
Answers must also be written in front of values greater than zero in column "f"
thanks GOOGLE TRANSLATE :)
 
I need to ask some more questions; I can see that I don't understand what's happening in this worksheet. Please tell me when I make a mistake:

In column B is a code (x, y or z) identifying a customer. I'll consider just customer x for now.

Row 2) On 2020-01-01, customer x orders 3000 rials' worth of something from your company. Column E shows that the total amount sold so far is 3000.

Row 3) He orders another 4000 worth of your product. Col E says the total sale is now 7000.

Row 4) He pays 2000. (This is what you mean by "settling" the account, right?) Col E still shows total sales of 7000; col F now shows 2000 "cleared".

In rows 5 and 6 he pays another 500 and 1000.

Row 7) He pays 20 000. He now has paid more than the total sale so far.

At this point I conclude that I've misunderstood what's happening in this worksheet. Where did I go wrong?

And you say you put a note n H6 that "shows how to calculate". But I don't see that; in H6 I see not a calculation but simply the number 3.5, and the note for H6 says this:
OliveSo:
500 of (1398/01/01)
500 of (1398/01/02)

I don't understand yet what you want to calculate in H.
 
Hello again my dear friend
You got it right
In row2 and 3, he bought a total of 7000 Rials and in row 4, he settled 2000 Rials
Column "c" "Sales
Column "" d "" Settlement
Column "" e "" collects total sales
And the "" f "column is the sum of the total settlement."
Sorry, I used Persian history in the notes:

1399/01/01 = 2020/01/01

1399/01/02 = 2020/01/02

1399/01/07 = 2020/01/07

In row 7, it has settled 20,000 Rials, which means that it must have paid 16,500 Rials as an advance payment
It must identify and calculate the source of calculating the date as much as 16,500 from the sale of row 9 (80,000) Rials.
In fact, the computational source of row 4 and row 5 must be row 2

But to calculate row 7, part of row 2 and part of row 3 must be identified.
Of course, I wrote only one example in this example, and in reality it may not be the place to pay and settle such an account, so a dynamic formula must be developed that identifies itself.

The formula to be written in h6:

=((500*(TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/01","yyyy-mm-dd"))+(500*(TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/02","yyyy-mm-dd")))))/1000

I tried to get what I wanted in the "g" column, but the answers I got are not accurate.
In fact, I need to get to the answers written in column "h"
I have uploaded a new file. Where the "h" column has a formula.
If needed :
Telegram: +989361716377
Whats App:+989361716377
very very Thanks
 

Attachments

  • 20200407 Newest.xlsb
    25.2 KB · Views: 5
Ok, I'm getting closer :). Those numbers in the notes are current dates but use a different year—counting, I now see, from what in English we'd probably call the Ascension (Isra and Mi'raj). And I'm now looking at your new worksheet. You're trying to calculate a figure in G, and you're dissatisfied with the results of your formula; you want a formula that produces, instead, the sample values you display H. But I still don't understand what you want the value to be—what the result is supposed to represent.

Let's take a look at the formula you listed earlier today:
Code:
=((500*(TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/01","yyyy-mm-dd"))+(500*(TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/02","yyyy-mm-dd")))))/1000

It look to me as though this part
Code:
TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/02","yyyy-mm-dd")
is supposed to calculate the difference days between the two dates—that is, it should produce the number 3. If so, the entire formula simplifies to
Code:
=((500*3)+(500*3))/1000
Am I right so far? If so, the final result should be (1500+1500)/1000=3. But in row H6 you say you want 3.5. So I don't understand your goal, yet.

You also say (referring to row 7, I think) "It must identify and calculate the source of calculating the date as much as 16,500 from the sale of row 9 (80,000) Rials." But there's nothing about 80 000 rials on row 9. And "...the computational source of row 4 and row 5 must be row 2", which sounds like you want the result in G to be a row number. But that can't be right, either, because you say the correct answer in row 6 should be 3.5, which cannot be a row number. And what does it mean to say that the "source" of rows 4 and 5 is row 2? Because that's when the first sale was made? In that case, the source of all the rows is row 2.

I ask these questions not to prove you wrong, but to help you understand what's confusing me; maybe it'll help you explain it to me better.

I think I need you to explain in words what G is supposed to represent. Like this: "In G I want to see the number of the latest row in which the customer made a partial payment", or "...the number of days it will take to settle the account if the user pays off the debt 5000 rials at a time" or any description like that.
 
Ok, I'm getting closer :). Those numbers in the notes are current dates but use a different year—counting, I now see, from what in English we'd probably call the Ascension (Isra and Mi'raj). And I'm now looking at your new worksheet. You're trying to calculate a figure in G, and you're dissatisfied with the results of your formula; you want a formula that produces, instead, the sample values you display H. But I still don't understand what you want the value to be—what the result is supposed to represent.

Let's take a look at the formula you listed earlier today:
Code:
=((500*(TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/01","yyyy-mm-dd"))+(500*(TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/02","yyyy-mm-dd")))))/1000

It look to me as though this part
Code:
TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/02","yyyy-mm-dd")
is supposed to calculate the difference days between the two dates—that is, it should produce the number 3. If so, the entire formula simplifies to
Code:
=((500*3)+(500*3))/1000
Am I right so far? If so, the final result should be (1500+1500)/1000=3. But in row H6 you say you want 3.5. So I don't understand your goal, yet.

You also say (referring to row 7, I think) "It must identify and calculate the source of calculating the date as much as 16,500 from the sale of row 9 (80,000) Rials." But there's nothing about 80 000 rials on row 9. And "...the computational source of row 4 and row 5 must be row 2", which sounds like you want the result in G to be a row number. But that can't be right, either, because you say the correct answer in row 6 should be 3.5, which cannot be a row number. And what does it mean to say that the "source" of rows 4 and 5 is row 2? Because that's when the first sale was made? In that case, the source of all the rows is row 2.

I ask these questions not to prove you wrong, but to help you understand what's confusing me; maybe it'll help you explain it to me better.

I think I need you to explain in words what G is supposed to represent. Like this: "In G I want to see the number of the latest row in which the customer made a partial payment", or "...the number of days it will take to settle the account if the user pays off the debt 5000 rials at a time" or any description like that.

Sorry 16,500 must be calculated from row 8. I mistakenly said row 9
Let me explain in another way:
Simply put, I sampled what I wanted in the "sample" sheet of the new file and wrote the answer
However, this formula cannot be used because the sales amounts are not equal to the settlement amounts
There are 4 modes:
We may have 5 sales and a settlement
Maybe we have 1 sale and 5 settlements
Maybe 1 sale and a settlement
In some cases, the settlement is done before the sale is made (ie prepayment)
I attached the new file


{"Output in sequence (FIFO or First In, First Out) is one of the ways to organize data control according to time and prioritization. This term describes the principle of queuing processing technique or meeting the demand offered by the "first input, first service recipient" (FCFS) solution: each bead that is entered earlier is examined sooner, and each bead is entered later. He waits until the deeds done on the first bead are finished."}
 

Attachments

  • 20200407 Newest.xlsb
    27.5 KB · Views: 9
I'm uploading a new file, which will help you understand the subject very, very well
Thanks dear friend
Ok, I'm getting closer :). Those numbers in the notes are current dates but use a different year—counting, I now see, from what in English we'd probably call the Ascension (Isra and Mi'raj). And I'm now looking at your new worksheet. You're trying to calculate a figure in G, and you're dissatisfied with the results of your formula; you want a formula that produces, instead, the sample values you display H. But I still don't understand what you want the value to be—what the result is supposed to represent.

Let's take a look at the formula you listed earlier today:
Code:
=((500*(TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/01","yyyy-mm-dd"))+(500*(TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/02","yyyy-mm-dd")))))/1000

It look to me as though this part
Code:
TEXT("2020/01/05","yyyy-mm-dd")-TEXT("2020/01/02","yyyy-mm-dd")
is supposed to calculate the difference days between the two dates—that is, it should produce the number 3. If so, the entire formula simplifies to
Code:
=((500*3)+(500*3))/1000
Am I right so far? If so, the final result should be (1500+1500)/1000=3. But in row H6 you say you want 3.5. So I don't understand your goal, yet.

You also say (referring to row 7, I think) "It must identify and calculate the source of calculating the date as much as 16,500 from the sale of row 9 (80,000) Rials." But there's nothing about 80 000 rials on row 9. And "...the computational source of row 4 and row 5 must be row 2", which sounds like you want the result in G to be a row number. But that can't be right, either, because you say the correct answer in row 6 should be 3.5, which cannot be a row number. And what does it mean to say that the "source" of rows 4 and 5 is row 2? Because that's when the first sale was made? In that case, the source of all the rows is row 2.

I ask these questions not to prove you wrong, but to help you understand what's confusing me; maybe it'll help you explain it to me better.

I think I need you to explain in words what G is supposed to represent. Like this: "In G I want to see the number of the latest row in which the customer made a partial payment", or "...the number of days it will take to settle the account if the user pays off the debt 5000 rials at a time" or any description like that.
 

Attachments

  • FIFO MethodTest2.xlsx
    15.6 KB · Views: 14
The latest worksheet is much neater, but I still understand what your answer (now in column E) is supposed to represent. For example, your sample has one sale and one settlement, and the "true answer" is 2—but two what? In the third sample, one sale and two settlements (the numbers 1000, 500 and 500), the "true answer is 15; but fifteen what?

From the latest worksheet it looks like it must be days. In row 3, the true answer is 2, which is how many days after the sale the account was settled. The same seems to be true of rows 7 and 8; each is the length of time between the original sale and the date of the (partial or complete) settlement.

But it's not always the same. In row 4 the "true answer" is negative, possibly because the customer paid before ordering 80 000 rials' worth of goods — but he paid 4 days before the order, so why isn't the true answer -4 rather than -1? And in row 12 you want the true answer to be 19.67; I don't see how that corresponds to a three consecutive orders of 10K followed by a settlement of 30K. What does 19.67 mean?

Looking at the formula, I see how it's calculated: 29 10K-rial days plus 20 10K-rial days plus 10 10K-rial days, all divided by 30K. Starts out looking like it's going to be a calculation of interest on the money owed, but doesn't finish up that way. And this calculation doesn't seem to have any similarity to the calculations for the other samples.
 
Incidentally, exactly what I want is the exact last file.
With the difference that (the average difference between the settlement date and the sales date that it includes.)
By entering the information in the "Sales" section of the "FIFO MethodTest2" file in the "e: g" columns, you will fully understand the issue.
I hope I get it right. :)
 
In the latest worksheet I see "Total and Profit of Closing Stock as per FIFO stock valuation Method"; this I understand. (I work in computer security, but my college degree is in Accounting.) In rows 3 through 12, various purchases increase the number of units in inventory, and to the value of that inventory (according to what you paid for each unit). In row 13 you sold some of that inventory—under FIFO, the first 32 units. You paid 44 800 rials for those 32 units, and received 64 000 rials for them. Inventory is reduced by 32 units; the value of inventory is reduced by 44 800 rials; and profit is recorded for the remaining 19 200 rials.

Whoever gave you the formula in column I used SUMPRODUCT a lot. I've never had occasion to use SUMPRODUCT, so maybe, after all the time you've spent with me, I still won't be able to help you. But I at least understand what you're doing in this worksheet, keeping track of the size and value of your inventory.

Now, how does this relate to your request? You wrote "the average difference between the settlement date and the sales date that it includes", so I think I was on the right track when I said, last time, it has to do with the number of days. But the average number of days. So going back to your second worksheet, 20200407 Newest-1.xlsb:

Row 3: The "average" number of days between payment and sale is 2.
Row 7: Settlement is 5 days after the sale.
Row 8: Remaining settlement is 15 days after the sale.
Row 12: Average of of 29 days (for the first 10K units), 20 days (the second 10K units) and 10 days (the last 10K units), which is 19 2/3 days. Got it. It happens in this case that all three sales were for the same amount, but I suppose you want to weight the averages by the size of each purchase, so if the sales amounts on those three days had been 5K, 10K and 15K units—the 5K sale being on the 1st of the month—the average would have come to 16.5 instead.

If the above is right, then I take it your original question is how to calculate that in Excel. Maybe someone much smarter than I can come up with a formula that will do it, but I think it'll have to be a VBA program. Maybe we can make it a worksheet function, one you write yourself. The question in my mind is how to track the value of inventory at each point, so that the calculation for a sale on line 293 will correctly understand which units (from which purchase date) are being sold.

We can figure that out. But first, have I finally understood and correctly described what you want?
 
Back
Top