openoffice.org - List Comprehension in an Open Office Spreadsheet - Stack Overflow

admin2022-05-09  70

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?

Answers:

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?

Answers:

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.

Answers:

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)

转载请注明原文地址:https://www.u19.cn/read-99754.html

New Post(0)