Days between in- and outgoing for a total average.

Audorin

New Member
Joined
Nov 28, 2021
Messages
8
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello everyone,

I`ve been going absolutely mad with an issue I just can't seem to get my head around.
I'll try to give an example to best detail the issue on hand: Imagine I get a penalty fee by having a too fast of a turnover of the cattle I trade, so If I re-sell the first day it's 17% fee and if I sell after 113 days it's as low as 7% fee.

Bilde_2021-11-28_213900.png

(Example just given for context)

I've sorted all the transactions by date, name if it's sold or bought, price.
Bilde_2021-11-28_214651.png
Bilde_2021-11-28_214559.png


So all I want is the average amount of days between each transaction when the the cattle was bought, to the date the cattle was sold. Instead of calling them cattle, cattle1, and so on..I've given them personal names. (Tore Vagle, Rafal etc.) So I'm trying to get a formula to use the name as a criteria, this since the name can jump around on the list due to having sorting functions (sorting by date, name, value and so on). The only transactions I'm out after are the ones that have been bought and sold, not just bought. So how can I go about using the personal name as a criteria, taking the IN date, then the OUT date (on two seperate sheets) and calculating the number of days the cattle have been in my ownership.

The average days ownership per (all) cattle will help me calculate the fee on all the transactions in a very simple matter. It's just that the formula it self seems a bit hard to make now when my brain has completely shut down on the issue.

Hopeing for a helping hand here, at least to lead me in the right direction!

Thank you!

Per Å
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
so if you use the SOLD sheet only to get the average - then that solves issue
The only transactions I'm out after are the ones that have been bought and sold, not just bought.

Next you could add a column to the sold data with Days
Then you could lookup the date from the Bought Sheet
Index(Sheet-Bought!date-column, match ( cattle name cell , Sheet-Bought!name-column,0))
that returns the date
now subtract that from the sold date

Sold date for name - Index(Sheet-Bought!date-column, match ( cattle name cell , Sheet-Bought!name-column,0))
Then you have the days

heres is a simple mock up in 1 sheet so you can see the idea

Book3
ABCDEFGHIJK
1Bought SheetSold Sheet
2dateCattle Namecolumn 1pricedateCattle Namecolumn 1priceDate BoughtDays Owned
31/1/21fredBought10/1/21fredsold1/1/21273
410/1/21HarryBought11/1/21Harrysold10/1/2131
5
Sheet3
Cell Formulas
RangeFormula
J3:J4J3=INDEX($A$3:$A$4,MATCH(G3,$B$3:$B$4,0))
K3:K4K3=F3-J3
 
Upvote 0
Thank you very much etaf. It's a bit late, so I just skimmed over it, but this looks like the sollution on the first glance. Appreciate the fact that you probaly saved my sleep for the entire week right here and now. Much love!
 
Upvote 0
you are welcome
if you post a sample sheet with actual data , ranges etc , using the XL2BB Add-in see menu or my signature
maybe able to write something specifically using your data
Or put a sample onto a share like onedrive/dropbox/google drive

otherwise post any more clarification questions here
I'm out a lot of tomorrow, so others may answer, or it will be late monday/tuesday
 
Upvote 0
Hoping this works. Something fishy going on with the days. Feel free to take a look at it.Need to hit the sack, will look more on it in a few hours!

LLL.xlsm
ACDEIJKLMNOPQRTUVYZAA
1STATSSOLDSTATSBOUGHT
2TOTAL SOLD$ 12,642,095TOTAL SOLD$ 8,281,869
3AVG SOLD$ 268,981AVG SOLD$ 116,646
4TOTAL TRANSACTIONS47TOTAL TRANSACTIONS71
5DatePlayersActionTo/FromPriceTSIDaysDays owned2021RevenueInvestmentsDatePlayersActionTo/From®PriceTSI
65/10/21Xander AbbenhuisSoldGrolsche Boys18000001,76028/11/21-54september 2021$ -$ 202,00029/9/21Xander AbbenhuisBoughtZanarkand Duggles(R)10200001,710
710/10/21Willy CourtmanSoldschleiferteam161000075028/11/21-49oktober 2021$ 2,469,500$ 1,879,81129/9/21Rafał JaśkiewiczBoughtGKS Najmansi(R)5000001,290
810/10/21Rafał JaśkiewiczSoldschleiferteam10500001,09028/11/21-49november 2021$ 10,172,595$ 6,200,05829/9/21Andreas WeißburgBoughtTC Shanghai(R)1400001,390
910/10/21Andreas WeißburgSoldEscudos Portadores Del Sur7980001,23011/10/21-1desember 2021$ -$ -29/9/21Willy CourtmanBoughtThe Rampaging Raccoons(R)140000780
Sold Bought
Cell Formulas
RangeFormula
C2,T2C2=SUM(I6:I9999)/10
C3,T3C3=AVERAGE(I6:I9999)/10
C4C4=COUNTA(I6:I9999)
T4T4=COUNTA(X6:X9999)
I6:J9,Z6:AA9I6=VALUE(TEXTJOIN("",TRUE,IFERROR(MID(F6,SEQUENCE(20),1)+0,"")))
K6K6=INDEX($R$6:$R$76,MATCH(C6,T6:T76))
L6:L9L6=[@Date]-[@Days]
K7:K9K7=INDEX(R7:R77,MATCH(C7,T7:T77))
O6,O9O6=SUMIFS(Table5[Price],Table5[Date],">="&N6,Table5[Date],"<="&EOMONTH(N6,0))
P6:P9P6=SUMIFS(Table4[Price],Table4[Date],">="&N6,Table4[Date],"<="&EOMONTH(N6,0))/10
O7:O8O7=SUMIFS(Table5[Price],Table5[Date],">="&N7,Table5[Date],"<="&EOMONTH(N7,0))/10
 
Upvote 0
Also just to add, there are a few hidden collums there. It's data I don't need to see, but collums that needs to be there since the database I copy it from comes in a certain format.
 
Upvote 0
xl2bb does not show the data in hidden columns - so i just get value
also need to understand a little more about the sheet layout

date in column r = bought date
date in column a = sold date

so somewhere associated with sold
=INDEX($r$6:$r$9,MATCH(c6,$t$6:$t$9,0))
returns the bought date

the a6- INDEX($r$6:$r$9,MATCH(c6,$t$6:$t$9,0))
is days old

5/10/21 - 29/9/21
= 6days
 
Upvote 0
which i see you do have in K6 , but NO $ for the T range and so it will change as you copy down - although a larger range
AND 0 for an exact match have to lookup what the default is - probably 0

=INDEX($R$6:$R$76,MATCH(C6,$T$6:$T$76,0))

then
A6 - INDEX($R$6:$R$76,MATCH(C6,$T$6:$T$76,0))

As you can see in M6 - i get the 6 days as expected
Book4
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1STATSSOLDSTATSBOUGHT
2TOTAL SOLD#VALUE!TOTAL SOLD#VALUE!
3AVG SOLD#VALUE!AVG SOLD#VALUE!
4TOTAL TRANSACTIONS4TOTAL TRANSACTIONS0
5DatePlayersActionTo/FromPriceTSIDaysDays owned2021RevenueInvestmentsDatePlayersActionTo/From®PriceTSI
644474Xander AbbenhuisSoldGrolsche Boys#VALUE!#VALUE!44468=[@Date]-[@Days]644440=SUMIFS(Table5[Price],Table5[Date],">="&N6,Table5[Date],"<="&EOMONTH(N6,0))=SUMIFS(Table4[Price],Table4[Date],">="&N6,Table4[Date],"<="&EOMONTH(N6,0))/1044468Xander AbbenhuisBoughtZanarkand Duggles(R)#VALUE!#VALUE!
744479Willy CourtmanSoldschleiferteam#VALUE!#VALUE!44468=[@Date]-[@Days]44470=SUMIFS(Table5[Price],Table5[Date],">="&N7,Table5[Date],"<="&EOMONTH(N7,0))/10=SUMIFS(Table4[Price],Table4[Date],">="&N7,Table4[Date],"<="&EOMONTH(N7,0))/1044468Rafał JaśkiewiczBoughtGKS Najmansi(R)#VALUE!#VALUE!
844479Rafał JaśkiewiczSoldschleiferteam#VALUE!#VALUE!44468=[@Date]-[@Days]44501=SUMIFS(Table5[Price],Table5[Date],">="&N8,Table5[Date],"<="&EOMONTH(N8,0))/10=SUMIFS(Table4[Price],Table4[Date],">="&N8,Table4[Date],"<="&EOMONTH(N8,0))/1044468Andreas WeißburgBoughtTC Shanghai(R)#VALUE!#VALUE!
944479Andreas WeißburgSoldEscudos Portadores Del Sur#VALUE!#VALUE!#N/A=[@Date]-[@Days]44531=SUMIFS(Table5[Price],Table5[Date],">="&N9,Table5[Date],"<="&EOMONTH(N9,0))=SUMIFS(Table4[Price],Table4[Date],">="&N9,Table4[Date],"<="&EOMONTH(N9,0))/1044468Willy CourtmanBoughtThe Rampaging Raccoons(R)#VALUE!#VALUE!
Sheet1
Cell Formulas
RangeFormula
C2,T2C2=SUM(I6:I9999)/10
C3,T3C3=AVERAGE(I6:I9999)/10
C4C4=COUNTA(I6:I9999)
T4T4=COUNTA(X6:X9999)
I6:J9,Z6:AA9I6=VALUE(TEXTJOIN("",TRUE,IFERROR(MID(F6,SEQUENCE(20),1)+0,"")))
K6K6=INDEX($R$6:$R$76,MATCH(C6,T6:T76))
K7:K9K7=INDEX(R7:R77,MATCH(C7,T7:T77))
M6M6=A6 - INDEX($R$6:$R$76,MATCH(C6,$T$6:$T$76,0))
 
Upvote 0
xl2bb does not show the data in hidden columns - so i just get value
also need to understand a little more about the sheet layout

date in column r = bought date
date in column a = sold date

so somewhere associated with sold
=INDEX($r$6:$r$9,MATCH(c6,$t$6:$t$9,0))
returns the bought date

the a6- INDEX($r$6:$r$9,MATCH(c6,$t$6:$t$9,0))
is days old

5/10/21 - 29/9/21
= 6days
The hidden columns have data that should be displayed as numbers, but are registered as text. So the columns you can see have codes to extract the text from the hidden columns and make them numbers. "Price" And TSI (Total Skill Index), it's really just some data that doesn't matter much at all. I could as well hide that.

Just tried that code of yours, and it worked like a charm! :love:
I think I should be able to start making graphs and extract the data to a dashboard then. The reason I'm doing this is mostly to just improve in excel, and the excel sheet is based on a virutal football club.

Appreciate this a lot. Very pleased. I've really tried a lot of sollutions, but just couldn't make it happen.
Many many obstacles, but instead of having a "bought" sheet, and a "sold" sheet just gathered all the data in the same sheet. First then things started to work out. When I did the (sheet!xx, it just didn't really add up. Some of it worked, some did not.

So I'm happy most of the data is getting complete now and I can start creating the dashboard for a more visual view of the data!

Thank you again!

Good night.
 
Upvote 0
you are welcome
When I did the (sheet!xx, it just didn't really add up. Some of it worked, some did not.
it should work with different sheets , but needs the $ as i posted on both ranges
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

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