Formula to count consecutive zeros at the end of a row

Ishmael

New Member
Joined
Jul 26, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a report that shows how many views datasets have each week. For each row I wish to calculate 2 values:
- Total Zero = The number of weeks with zero views after the data has been viewed in a prior week
- Consecutive Zero = The number of consecutive weeks with zero views, where the most recent week (week 10) has zero views

I have attached an image of a table to illustrate my data with the final 2 columns showing the answer that i want the formulas to generate.


Hopefully there is a whiz on here who can help!
 

Attachments

  • ExcelFormulaQuery.jpg
    ExcelFormulaQuery.jpg
    65.6 KB · Views: 24

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
What determines if the data has been viewed in a prior week?

Also, it would be more useful if you could give us the data in a format that we could copy and paste from even if it's you just copying and pasting from your spreadsheet.
 
Upvote 0
Try:

Book2
ABCDEFGHIJKLM
1DatasetWeek1Week2Week3Week4Week5Week6Week7Week8Week9Week10Total ZeroConsecutive Zero
2A0000340001041
3B1185000000077
4C0008801010042
5D000000001100
6E100000000180
Sheet3
Cell Formulas
RangeFormula
L2:L6L2=IFERROR(COUNTIF(INDEX(B2:K2,XMATCH(TRUE,B2:K2<>0,0)):K2,0),0)
M2:M6M2=10-XMATCH(TRUE,B2:K2<>0,0,-1)
 
Upvote 1
Solution
Another option for the 'Total Zero' count
Excel Formula:
=LET(t,--CONCAT(B2:K2,1),LEN(t)-LEN(SUBSTITUTE(t,0,"")))
 
Upvote 0
One more option for "Total Zero".
Excel Formula:
=SUM(--(DROP(B2:K2,,XMATCH(TRUE,B2:K2<>0))=0))
 
Upvote 0
Wow!!! Thank you all so much for your efforts, I really appreciate it :love:
 
Upvote 0
Glad we could help! :)

Peter, I believe your formula would have a problem if one of the non-zero numbers has a 0 in it, like 20 or 104.
 
Upvote 0
Peter, I believe your formula would have a problem if one of the non-zero numbers has a 0 in it, like 20 or 104.
Absolutely correct Eric. My formula should be disregarded. :oops:
 
Upvote 0

Forum statistics

Threads
1,223,929
Messages
6,175,457
Members
452,643
Latest member
gjcase

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