Averageifs #DIV/0! solution?

笑着哭i 提交于 2019-12-11 17:44:11

问题


I know this question has been asked 100's of times, but... So I have this formula that gives me #DIV/0!.

=AVERAGEIFS(Sheet1!L2:L, Sheet1!M2:M, "WIN",Sheet1!E2:E, ">=" &A7, Sheet1!E2:E, "<" &A8)

I know I can wrap it around IFERROR(formula,"") or IFERROR(formula,0) and it works. But there are problems with it in case of real errors with it in the future.

I tried to wrap it around IF(formula,"") or IF(formula,0). But it doesn't work, I still get the same #DIV/0!.

And how about these, can I use something not to show 0 in the empty cells?

=COUNTIFS(Sheet1!M2:M, "WIN",Sheet1!E2:E, ">=" &A7, Sheet1!E2:E, "<" &A8)

=SUMIFS(Sheet1!L2:L, Sheet1!M2:M, "LOSS",Sheet1!E2:E, ">=" &A7, Sheet1!E2:E, "<" &A8)

I tried the above IF(...,"") and IF(...,0) and I either get #DIV/0!, ERROR or FALSE.

EDIT

So for clarification I'm working on sheets 2 "sample doc" included. This spreadsheet is to keep track of my trades that I will fill out over time. That's why most of sheet 1 is empty at the time. As you can see there's a lot of #DIV?0! on sheet 2. I know I get these because there's no match to most of these on sheet 1. Some of them will get filled out over time, but some of them might not get filled out for a while. As you can see the formulas work with the couple of "test" entries I made on sheet 1 to make sure everything works.

That's why I asked for a better solution then wrapping the formulas in IFERROR(...,""). But if that's the only and best solution then so be it.

sample doc link

Thank you.


回答1:


Nacho.

I replicated your formula on a Google Sheet. It doesn't have a problem with 0 nor empty values. It just doesn't count them.

It does have a problem when nothing matches one of the criteria you specified.

Then it gives #DIV/0.

You should check why you're not getting matches in one or more of your criteria. It could be a range problem with your >= , < conditions.

Good Luck


Edit.

However, I adapted your formula to check if there isn't going to be a match before calulating:

=IF(COUNTIF(B3:B15;"WIN")=0;"No WIN matches";IF(COUNTIF(B3:B15;">=" &A7)=0;"No >= matches"; IF(COUNTIF(B3:B15;"<" & A8)=0;"No < matches";AVERAGEIFS(E3:E;B3:B;"WIN";D3:D;"<20";C3:C;">10"))))



回答2:


=IFERROR(
 IF(AND(M:M="WIN",
        ISNUMBER(A7),
        ISNUMBER(a8),
        ISNUMBER(E:E),
        ISNUMBER(L:L)), AVERAGEIFS(Sheet1!L2:L, Sheet1!M2:M, "WIN",
                                                Sheet1!E2:E, ">="&A7, 
                                                Sheet1!E2:E, "<"&A8), ),
 "anverageifs error")



来源:https://stackoverflow.com/questions/54777684/averageifs-div-0-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!