Spreadsheet formula for org spreadsheet

I have a table as follows:

| Xn | S | Pn | | 0 | 0 | 0 | | 1 | 0 | 1 | | 0 | 1 | 0 | | 1 | 1 | 0 | 

I would like to search the columns Xn and S and return the value of Pn for which Xn=1 and S=0 .

Can anyone advise how I can do this?

+6
source share
2 answers
 #+tblname: example-table | Xn | S | Pn | | 0 | 0 | 0 | | 1 | 0 | 1 | | 0 | 1 | 0 | | 1 | 1 | 0 | #+source: compute-table #+begin_src emacs-lisp :var table=example-table (require 'cl) (loop for (xn s pn) in (rest table) when (and (= xn 1) (= s 0)) collect pn) #+end_src #+results: compute-table | 1 | 
+5
source

Using org-babel: Name the table and use it as an input for a function that searches in your chosen language (from many languages โ€‹โ€‹supported by org).

In pseudo code:

 #+tblname: my_table |Xn|S|Pn| | 0|0|9 | [...] #+name filter_table #+begin_src lang :var tbl=my_table :results output filter tbl # tbl (my_table by default) is passed in as array of arrays (or list of lists) print matching Pn #+end_src 
+2
source

Source: https://habr.com/ru/post/907541/


All Articles