A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Regarding your issue, it seems like you want to keep only the rows where at least one column from C_1 to C_20 has a value greater than 0 and remove the rows where all columns are zero.
Using + for OR logic works for a couple of columns, but it's not practical when you need to cover 20. There are two cleaner approaches you can try.
- Using BYROW (Excel 365)
=FILTER(A2:W100, BYROW(D2:W100, LAMBDA(r, MAX(r)>0)), "N")
- Using MMULT (Excel 365 / Excel 2021)
=FILTER(A2:W100, MMULT(D2:W100, SEQUENCE(20,1,1,0))>0, "N")
How to apply:
- Replace A2:W100 with your full data range
- Replace D2:W100 with the range that covers your C_1 to C_20 columns only
- If using Option 2, make sure the 20 in SEQUENCE(20,1,1,0) matches the number of C columns you have
Note: If Option 1 returns a #NAME? error, it means your Excel version does not support BYROW. In that case, please use Option 2 instead.
I've tested both formulas on my end using a small sample with 6 rows and 5 columns (C_1 to C_5). The sample data has 2 rows with all zeros and 4 rows with values greater than 0.
Using BYROW:
=FILTER(A2:H7, BYROW(D2:H7, LAMBDA(r, MAX(r)>0)), "N")
The result correctly returned only the 4 rows that have at least one value greater than 0, and the 2 all-zero rows were filtered out.
Using MMULT:
=FILTER(A2:H7, MMULT(D2:H7, SEQUENCE(5,1,1,0))>0, "N")
Same result, the 4 rows with values were kept and the 2 all-zero rows were removed.
Both formulas produce the same output, so you can use whichever one works in your version of Excel.
Hopefully this helps resolve the issue, if anything is unclear or the issue persists, feel free to reply below.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.