LibreOffice Calc count the number of distinct occurrences

自闭症网瘾萝莉.ら 提交于 2021-02-07 02:46:18

问题


What formula in LibreOffice Calc will count the number of distinct Week_Number occurrences? The answer should be 2.


回答1:


This question has been asked many times before. One way is to enter the following formula in B6 and then press Ctrl+Shift+Enter:

=SUM(1/COUNTIF(B2:B5,B2:B5))

Other solutions are described at:

  • https://forum.openoffice.org/en/forum/viewtopic.php?f=9&t=47223
  • https://superuser.com/questions/238656/openoffice-get-distinct-values-from-column
  • https://askubuntu.com/questions/114732/different-values-in-one-column

I prefer using a database such as LibreOffice Base instead, with a simple query:

SELECT COUNT(DISTINCT Week_Number) FROM Weeks_Table;



回答2:


I tried using =SUM(1/COUNTIF(A:A,A:A)) on a column with 2500 rows, and got a divide by zero error for my trouble, (After hours of computation time.). Then I thought of:

=SUMPRODUCT( A$3:A1000000<>OFFSET(A$3:A1000000,-1,0)) which works to find the number of distinct values in SORTED column A2... by finding when the value in cell Ax is different than the value in the cell directly above it (OFFSET(...,-1,0)).

Now if we only had a SORT array function this problem would be solved.



来源:https://stackoverflow.com/questions/38284060/libreoffice-calc-count-the-number-of-distinct-occurrences

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!