Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LibreOffice Calc count the number of distinct occurrences

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

enter image description here

like image 934
Dave Kirkby Avatar asked Jul 09 '16 16:07

Dave Kirkby


People also ask

How do you count unique values in Libreoffice Calc?

A quick way for that is: Click into the Pivot table and press Strg + * (in the numpad). Then set a filter by Data > More Filters > Standard Filter . In field Field name select Count - your label. In field Condition select Largest and in field Value write 100.

How do you count distinct items?

The COUNT DISTINCT function returns the number of unique values in the column or expression, as the following example shows. SELECT COUNT (DISTINCT item_num) FROM items; If the COUNT DISTINCT function encounters NULL values, it ignores them unless every value in the specified column is NULL.

How do I count the number of distinct values in a column of a data table in R?

To get a count of unique values by each column I will use n_distinct from dplyr. Unique values in one column. If it is necessary to do that for all data frame columns then you can use R base functions sapply or lapply. The output will be in different formats.


1 Answers

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;
like image 52
Jim K Avatar answered Oct 11 '22 15:10

Jim K