使用SUMPRODUCT函数巧妙处理多条件判断
时间:2023-01-02 23:12:35
下面是要使用公式解决的问题:
如果值处于0%-25%,则返回0;处于16%-50%,则返回0.1;处于51%-75%,则返回0.2;处于76%-100%,则返回0.3;大于100%则返回0.4。
如下所示,值为80%,返回0.3。
通常,我们会考虑使用IF函数的公式:
=IF(AND(B3>=0,B3
太冗长了!如果条件更多,则需要增加更多的IF语句。
这里使用SUMPRODUCT函数编写了一个简洁的公式:
=SUMPRODUCT((B3>{0.25,0.5,0.75,1})*0.1)
我们来看看公式中的:
B3>{0.25,0.5,0.75,1}
用来将B3中的值进行分类,本例中的结果为:
{TRUE,TRUE,TRUE,FALSE}
将其与0.1相乘,得到:
{0.1,0.1,0.1,0}
将其传递给SUMPRODUCT函数:
=SUMPRODUCT((B3>{0.25,0.5,0.75,1})*0.1)
即:
=SUMPRODUCT({0.1,0.1,0.1,0})
由于SUMPRODUCT函数内只有一个数组,因此简单地将该数组元素值相加,得到结果:
0.3
注意,SUMPRODUCT函数不会直接处理TRUE/FALSE值的数组,因此,如果使用公式:
=SUMPRODUCT((B9>{0.25,0.5,0.75,1}))*0.1
结果将是0。
要得到正确的结果,需要将上面的公式修改为:
=SUMPRODUCT(1*(B10>{0.25,0.5,0.75,1}))*0.1
或者:
=SUMPRODUCT(–(B10>{0.25,0.5,0.75,1}))*0.1
标签:Excel函数,excel函数公式,excel表格制作,Excel教程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
windows7无线路由器无法使用的解决办法
2023-01-03 08:04:33
AutoCAD2010如何设置靶框的大小?AutoCAD2010设置靶框大小的方法
2023-05-17 10:17:13
![](https://img.aspxhome.com/file/2023/8/a333214_0s.jpg)
石大师装机大师一键重装系统教程
2023-04-08 19:57:10
![](https://img.aspxhome.com/file/2023/1/a274694_0s.png)
excel图表怎么标识重复值?
2022-02-26 14:45:57
![](https://img.aspxhome.com/file/2023/2/a141912_0s.png)
Win8系统如何开启系统自带的手写输入公式功能
2023-05-11 15:42:21
![](https://img.aspxhome.com/file/2023/29/a253133_0s.jpg)
DOS批处理命令实现自动复制指定的文件夹到其他位置
2022-11-03 15:17:38
![](https://img.aspxhome.com/file/2023/9/a342027_0s.jpg)
Pixelmator Pro 教程「1」,认识 Pixelmator Pro 界面
2022-10-02 09:19:46
![](https://img.aspxhome.com/file/2023/2/a201952_0s.jpeg)
word文档总分哪三个层次
2023-11-30 03:34:50
PowerPoint2003自动更正项的例外实例
2022-07-01 21:57:23
![](https://img.aspxhome.com/file/2023/10/a344695_0s.png)
点击工具栏的页面布局打印标题
2023-06-08 10:36:50
超实用Excel整理操作技巧
2022-01-16 05:08:59
![](https://img.aspxhome.com/file/2023/5/36255_0s.jpg)
ppt如何连续自动播放?
2023-06-29 07:45:17
![](https://img.aspxhome.com/file/2023/3/a295134_0s.jpg)
Win10 Edge浏览器查看历史记录的方法
2023-07-03 01:12:09
![](https://img.aspxhome.com/file/2023/26/a226871_0s.jpg)
新款M2 MacBook Air 将于 7 月 15 日发售
2023-12-22 16:16:57
![](https://img.aspxhome.com/file/2023/3/a202583_0s.png)
ppt中怎么制作出水中倒影图片?ppt中制作出水中倒影图片的方法
2023-06-28 01:32:25
![](https://img.aspxhome.com/file/2023/10/a350692_0s.jpg)
Win10蓝牙支持服务怎么启动?
2022-04-01 23:55:06
![](https://img.aspxhome.com/file/2023/25/a218370_0s.jpg)
win8.1系统运行绿色软件被拒绝访问的解决方法
2022-03-18 15:21:11
![](https://img.aspxhome.com/file/2023/28/a246224_0s.jpg)
小编教你华硕主板bios怎么进入
2023-01-23 07:16:03
![](https://img.aspxhome.com/file/2023/4/a307577_0s.png)
win10底部任务栏无响应是什么原因 win10底部任务栏无响应怎么解决
2022-03-08 02:47:33
![](https://img.aspxhome.com/file/2023/1/a272601_0s.png)
Excel 如何定义方案实例图解
2022-04-07 03:56:01
![](https://img.aspxhome.com/file/2023/7/a161187_0s.jpg)