Open Office 电子表格中的列表理解

发布于 2024-07-06 03:56:14 字数 286 浏览 7 评论 0原文

列表理解是一种非常有用的代码机制,可以在多种语言中找到,例如 Haskell、Python 和 Ruby(仅举几个我想到的例子)。 我对这个结构很熟悉。

我发现自己正在处理一个 Open Office 电子表格,并且需要做一些相当常见的事情:我想要计算一系列单元格中位于上限和下限之间的所有值。 我立即认为列表理解可以解决问题,但我在 Open Office 中找不到任何类似的东西。 有一个名为“COUNTIF”的函数,它类似,但不完全是我需要的。

Open Office 中是否有可用于列表理解的构造?

List Comprehension is a very useful code mechanism that is found in several languages, such as Haskell, Python, and Ruby (just to name a few off the top of my head). I'm familiar with the construct.

I find myself working on an Open Office Spreadsheet and I need to do something fairly common: I want to count all of the values in a range of cells that fall between a high and low bounds. I instantly thought that list comprehension would do the trick, but I can't find anything analogous in Open Office. There is a function called "COUNTIF", and it something similar, but not quite what I need.

Is there a construct in Open Office that could be used for list comprehension?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦萦几度 2024-07-13 03:56:15

假设:

  • 您的范围是 A1:A10
  • 您的下限是 B1
  • 您的上限是 B2

那么您想要的可以通过以下方式实现:(

=COUNTIFS(A1:A10, ">" & B1, A1:A10, "<" & B2)

您可能需要将逗号更改为分号,具体取决于您对小数点的语言偏好)

引用自安装的 OpenOffice 文档:

条件之间的逻辑关系可以定义为逻辑AND(连接)。 换句话说,当且仅当满足所有给定条件时,才会将给定 Func_Range 的相应单元格中的值纳入计算中。

此函数是 Office 应用程序开放文档格式 (OpenDocument) 标准版本 1.2 的一部分。 (ISO/IEC 26300:2-2015)

Assuming:

  • your range is A1:A10
  • your lower bound is at B1
  • your upper bound is at B2

then what you want can be achieved by:

=COUNTIFS(A1:A10, ">" & B1, A1:A10, "<" & B2)

(you might need to change commas into semicolons, depending on your language preference for decimal point)

Quoting from the installed OpenOffice documentation:

The logical relation between criteria can be defined as logical AND (conjunction). In other words, if and only if all given criteria are met, a value from the corresponding cell of the given Func_Range is taken into calculation.

This function is part of the Open Document Format for Office Applications (OpenDocument) standard Version 1.2. (ISO/IEC 26300:2-2015)

淡淡绿茶香 2024-07-13 03:56:14

CountIf 可以计算等于所选值的值。 不幸的是,似乎没有合适的候选函数来实现这种功能。 或者,您可以使用带有 If 的附加列来显示 1 或 0(如果值符合或不相应地显示 1 或 0):

=If(AND({list_cell}>=MinVal; {list_cell}<=MaxVal); 1; 0)

那么剩下的就是对这个附加列求和。

CountIf can count values equal to one chosen. Unfortunately it seems that there is no good candidate for such function. Alternatively you can use additional column with If to display 1 or 0 if the value fits in range or not accordingly:

=If(AND({list_cell}>=MinVal; {list_cell}<=MaxVal); 1; 0)

Then only thing left is to sum up this additional column.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文