Excel 中的双破折号 ( - - ) 有什么作用?

Jus*_*ing 5 worksheet-function microsoft-excel

--在 Excel 中有一些公式,实验证实这=--1确实是一个有效的公式,计算结果为 1。但是,谷歌搜索不返回任何内容。有什么作用--

Ray*_*ian 5

减号将标准 Excel 公式中的正数更改为负数。

使用两个减号--将 TRUE 和 FALSE 更改为数字:

=(1>2) =FALSE
=--(1>2) =0
=(2>1) =TRUE
=--(2>1) =1
Run Code Online (Sandbox Code Playgroud)

更重要的是,在数组公式中使用非常棒 -

从单元格开始获取这个表格 A1

Primary Secondary   Count
red     blue        10
blue    red         20
yellow  red         30
red     blue        40
purple  green       50
blue    red         60
red     red         70
Run Code Online (Sandbox Code Playgroud)

如果您想查看特定组合的数量,您可以使用这样的sumproduct -

=SUMPRODUCT(--(A2:A8="blue"),--(B2:B8="red"),C2:C8)
Run Code Online (Sandbox Code Playgroud)

通过对您的桌子执行此操作,这将为您提供 80(字面意思是乘法)-

blue    red    Count    Total
0   x   0   x   10   =   0
1   x   1   x   20   =   20
0   x   1   x   30   =   0
0   x   0   x   40   =   0
0   x   0   x   50   =   0
1   x   1   x   60   =   60
0   x   1   x   70   =   0
Run Code Online (Sandbox Code Playgroud)

本质上,它允许您使用真/假条件作为数组中的乘数。而这个公式

=SUMPRODUCT((A2:A8="blue"),(B2:B8="red"),C2:C8)
Run Code Online (Sandbox Code Playgroud)

将返回 0。这在countifs不能处理求和的时候很有用。

如果您正在寻找有关 google 的信息,您应该搜索的术语是double dash