UNIQUE function is not working in this case

Ahmed142 20 Reputation points
2026-06-17T17:40:19.9633333+00:00

Hello everyone,

I noticed that in Excel the Unique function is not working as expected, the explanation of this is illustrated in the following image, as I will insert a link to download the file by OneDrive at the end of this post:

User's image When I apply the UNIQUE function on the A1:A2 range it not works as expected it shows two times 13.62! while using UNIQUE function after using TRIM function is giving the wanted result, but the problem is that neither the cell A1 or A2 has any spaces, so what is the effect of TRIM function in this case?

so isn't this considered a problem that exist in UNIQUE function in Excel? or how to solve this problem without retyping the content of the cells A1 and A2 manulally or using TRIM function?

I use Windows and I use Microsoft Office Home and Business 2024

Here is the link to download the file:
https://1drv.ms/x/c/3b862aaec36e5e46/IQBjdaZuVt4pRLFh0g14TcxiAURKtlR4Y8rMISxT80JI4To?e=C9xqam

Microsoft 365 and Office | Excel | For home | Windows

2 answers

Sort by: Most helpful
  1. Ashish Mathur 102.2K Reputation points Volunteer Moderator
    2026-06-17T23:11:26.27+00:00

    Hi,

    Use this formula in cell C2

    =UNIQUE(REGEXREPLACE(A1:A2,"\s+",""))

    Hope this helps.

    User's image

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-06-17T17:40:38.7233333+00:00

    UNIQUE compares the underlying values in the array, not the formatted display. If the two cells in A1:A2 contain values that are numerically different (for example, one is a number and the other is text, or they differ beyond the displayed decimal places), UNIQUE will treat them as two distinct values and will therefore return both.

    TRIM works only on text. When TRIM is applied to the cells, Excel converts the values to text strings and removes any leading/trailing spaces inside those strings. After TRIM, the resulting text values become identical, so UNIQUE sees only one distinct value and returns a single result.

    This behavior is by design and not a bug in UNIQUE. To avoid retyping, normalize the data before calling UNIQUE, for example by:

    • Converting both cells to the same type and precision (e.g., using a helper column with a formula that rounds or converts to text), and then running UNIQUE on that normalized range.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.