Bug 166731 - Calc function UNIQUE gives incorrect results if all cells have the same value
Summary: Calc function UNIQUE gives incorrect results if all cells have the same value
Status: RESOLVED DUPLICATE of bug 127808
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.2.3.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-26 11:14 UTC by David Lynch
Modified: 2025-05-26 12:33 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Exhibits bug 166731 (10.60 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-05-26 11:15 UTC, David Lynch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Lynch 2025-05-26 11:14:06 UTC
Description:
See attached spreadsheet: input array {2,2,2,2} gives identical array as result.

Steps to Reproduce:
See attached spreadsheet.

Actual Results:
See attached spreadsheet

Expected Results:
See attached spreadsheet


Reproducible: Always


User Profile Reset: No

Additional Info:
Same results in safe mode.
Comment 1 David Lynch 2025-05-26 11:15:56 UTC
Created attachment 200961 [details]
Exhibits bug 166731
Comment 2 Xisco Faulí 2025-05-26 11:21:16 UTC
Thanks for reporting this issue.
This is a problem related with dynamic arrays since they are not fully supported in Calc.
Steps to fix it:
1. Select range F2:I2
2. Delete its content
3. Select cell F2
4. add formula =UNIQUE(A2:D2;1)

-> This time the array is only one cell.

*** This bug has been marked as a duplicate of bug 127808 ***
Comment 3 David Lynch 2025-05-26 12:06:13 UTC
Thank you. Your work-around works only because you know the answer! ... There is only one unique value in my input array.

In my use case, the whole point of using UNIQUE is to find out how many unique values in the input array. In all cases except when the values in my input array are identical, I can get the correct answer by counting the number of cells that are not #N/A in an output array from UNIQUE that is the same length are the input array. 

If I ensure that my input array contains at least 2 different values, with v1 and v2 the smallest, and make the output array the same length as the input, will the output be

 v1,v2,v3,...,vn,#N/A,#N/A,...,#N/A
 
 or are there other situations where I would get results different from the above?
 
 I can always ensure there are two different values on imput by including an impossible one: this is fine as a work-around.
 
 Is lack of full support for dynamic arrays temporary or longstanding?
Comment 4 Xisco Faulí 2025-05-26 12:33:15 UTC
it's a missing feature