Count days with specific balance

PAOLO7673

New Member
Joined
Jul 4, 2024
Messages
12
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone.
I need to count the number of days reaching a specific bank balance.
In Colum A the dates are listed, repeated dates as well
In Colum B the running balance with positive and negatives amounts.
I want to know how many days the negative balance occurred in a year( specified in a cell)
eg: in 2023 the balance below $1000 lasted 13 days.
Many thanks for helps.
paolo
 
would
=countif( Range with the values in, "<="&-1000)

or is this only where consecutive rows have less than 1000

if its the consecutive values
mayb e
=MAX(FREQUENCY(IF(B2:B10<-1000,ROW(B2:B10)),IF(B2:B10>=-1000,ROW(B2:B10))))

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Last edited:
Upvote 0
Hi everyone.
I need to count the number of days reaching a specific bank balance.
In Colum A the dates are listed, repeated dates as well
In Colum B the running balance with positive and negatives amounts.
I want to know how many days the negative balance occurred in a year( specified in a cell)
eg: in 2023 the balance below $1000 lasted 13 days.
Many thanks for helps.
paolo
 

Attachments

  • count days.JPG
    count days.JPG
    76.8 KB · Views: 13
Upvote 0
not following sorry -
you want the sum of anything less than 0 for a particular year

you image says
£323 for 2023
i see -400

so not sure why its 323 in you answer

BUT it would be a
=SUMIFS( C2:C1000, A2:A1000, ">="&DATEVALUE("1/1/"&G2), A2:A1000,"<="&DATEVALUE("31/12/"&G2), C2:C1000, "<"&0)

you could change to <=0 , but if it =0 , then wont change the result
did you want to use G3 in the formula -
=SUMIFS( C2:C1000, A2:A1000, ">="&DATEVALUE("1/1/"&G2), A2:A1000,"<="&DATEVALUE("31/12/"&G2), C2:C1000, G3)

Book2
ABCDEFGHI
1
212/1/23-100132023
312/2/23-1001<=0-5005
412/3/232
512/4/233
612/5/23-1001
712/6/23-1001
812/7/23-1001
97
1014
Sheet1
Cell Formulas
RangeFormula
D2D2=MAX(FREQUENCY(IF(C2:C10<-1000,ROW(C2:C10)),IF(C2:C10>=-1000,ROW(C2:C10))))
I3I3=SUMIFS( C2:C1000, A2:A1000, ">="&DATEVALUE("1/1/"&G2), A2:A1000,"<="&DATEVALUE("31/12/"&G2), C2:C1000, G3)
 
Upvote 0
not following sorry -
you want the sum of anything less than 0 for a particular year

you image says
£323 for 2023
i see -400

so not sure why its 323 in you answer

BUT it would be a
=SUMIFS( C2:C1000, A2:A1000, ">="&DATEVALUE("1/1/"&G2), A2:A1000,"<="&DATEVALUE("31/12/"&G2), C2:C1000, "<"&0)

you could change to <=0 , but if it =0 , then wont change the result
did you want to use G3 in the formula -
=SUMIFS( C2:C1000, A2:A1000, ">="&DATEVALUE("1/1/"&G2), A2:A1000,"<="&DATEVALUE("31/12/"&G2), C2:C1000, G3)

Book2
ABCDEFGHI
1
212/1/23-100132023
312/2/23-1001<=0-5005
412/3/232
512/4/233
612/5/23-1001
712/6/23-1001
812/7/23-1001
97
1014
Sheet1
Cell Formulas
RangeFormula
D2D2=MAX(FREQUENCY(IF(C2:C10<-1000,ROW(C2:C10)),IF(C2:C10>=-1000,ROW(C2:C10))))
I3I3=SUMIFS( C2:C1000, A2:A1000, ">="&DATEVALUE("1/1/"&G2), A2:A1000,"<="&DATEVALUE("31/12/"&G2), C2:C1000, G3)

I need the number of days (from first day till last day) the balance remained below zero or below a specific amount.
The 323 I mentioned is the total number of days from 11/01/2023 till 30/11/2023
Thanks for you fast reply!!
 
Upvote 0
thanks for the clarification
a little more complicated then
in the example

you have 2 - where it shows 400 on the 1/1/22
then -200 on the 3/1/22 - WHY 2 days ???

i think possibly need quite a few more examples of the permutations that may be needed

i may not be able to help here , i maybe missing the obvious and cannot see it - ...... looks like a MIN and a MAX dates BUT not following the example,

when is the start date and why , when is the end date and why - then we can get the MIN and MAX and take them away to get days

but as posted - rather than image use xl2bb or a share

Book2
ABCDE
1
21/1/23100
32/2/230or is this the start
43/23/23-100Start count of days - 3/3/23
54/4/230
65/4/230
75/10/23200
86/11/230
99/1/23-200
1010/2/230
1110/3/23-100last count of days 10/3/23
1211/4/23200
1312/4/23200
14
Sheet1


Note: Images are difficult to see , and also requires that I input all the data myself, which means I may make an error, which is very time consuming, and from my point of view less likely to get a response, if a complicated spreadsheet. Plus we cannot see any of the formulas used.

Therefore -

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Upvote 0
May be something like this, Input year in [$G$6]
Book3
ABCDEFGH
1dateamount in/outbalancedays with negative balanceresult
201/01/2250400year2023323
301/03/22-600-2002balance limit<=0
401/04/22400200
501/04/22500700
601/05/226001300year2022result
701/06/22-1.4-1001Days @ <0<02
801/07/22250150
901/08/2250200
1001/09/22100300
1101/09/2250350
1201/11/23-500-150
1302/02/23100-50
1402/05/23500
1506/06/23-200-200
1606/01/232000
1711/30/23100100323
1811/30/23200300
1911/30/23350650
2011/30/236001250
2112/31/23-1250
2201/01/24-500-250
2301/02/246003501
2401/03/24300650
2501/03/24250900
2601/03/24-2-1100
2712/01/24150-950
2812/01/24100-850
2912/31/2450-800
3001/01/258000364
Sheet3
Cell Formulas
RangeFormula
H7H7=SUM(--(FREQUENCY(IF((YEAR(A2:A30)=$G$6)*(C2:C30<0), MATCH(A2:A30, A2:A30, 0)), ROW(A2:A30)-ROW(A2)+1)>0))
 
Upvote 0
BANCA 22-24.xlsx
ABCDEFGH
1date amount in/out balancedays with negative balanceresult
201/01/202250400year2023146
303/01/2022- 600-2002balance limit<=0
404/01/2022400200
504/01/2022500700
605/01/20226001300
706/01/2022- 1.400-10013
807/01/2022250150
908/01/202250200
1009/01/2022100300
1109/01/202250350
1211/01/2023- 500-150
1302/02/2023100-50
1405/02/2023500
1501/06/2023- 200-200
1606/06/20232000146146
1730/11/2023100100
1830/11/2023200300
1930/11/2023350650
2030/11/20236001250
2131/12/2023- 1.000250
2201/01/2024- 500-2501
2302/01/2024600350
2403/01/2024300650
2503/01/2024250900
2603/01/2024- 2.000-1100
2701/12/2024150-950
2801/12/2024100-850
2931/12/202450-800
3031/12/20248000363364
Foglio1
Cell Formulas
RangeFormula
D3,D7D3=A3-A2
E7E7=+D3+D7
D16D16=SUM(A16-A12)
E16E16=+D16
C3:C30C3=+C2+B3
D30D30=A30-A26
E30E30=+D30+D22



Sorry, not getting the desired amount. Here is a coloured version that should make the calculation. For 2023 the TOTAL days with <=0 balance were 146 . Many thanks
 
Upvote 0
@PAOLO7673 Please check, Note: Date format "MMDDYY"
Book2
ABCDEFGHIJ
1DATEAMT IN/OUTBALANCEDAYS Negative BALManual Result
201/01/2250400year2023146
301/03/22-600-20022balance limit<=0
401/04/224002000
501/04/225007000
601/05/2260013000
701/06/22-1400-10011
801/07/222501500
901/08/22502000
1001/09/221003000
1101/09/22503500
1201/11/23-500-1500
1302/02/23100-502222
1402/05/2350033
1506/01/23-200-200116116
1606/06/23200055
1711/30/231001000
1811/30/232003000
1911/30/233506500
2011/30/2360012500
2112/31/23-10002500
2201/01/24-500-25011
2301/02/246003500
2401/03/243006500???
2501/03/242509000???
2601/03/24-2000-110011???
2712/01/24150-950333333
2812/01/24100-85000
2912/31/2450-8003030
3012/31/24800000
Sheet1
Cell Formulas
RangeFormula
J2J2=IFERROR(MAX(FILTER($A$2:$A$30,($D$2:$D$30<=0)*(YEAR($A$2:$A$30)=$I$2)))-MIN(FILTER($A$2:$A$30,($D$2:$D$30<=0)*(YEAR($A$2:$A$30)=$I$2))),0)
 
Upvote 0

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