Forum Discussion
Getting duplicate values in Power BI
- 1 year ago
Hi aditya_ghui
Please Check for Hidden Characters:
Even though you've used TRIM, there might be hidden characters or non-printing characters that are not visible.
Ensure that there are no extra spaces or special characters in your PRODUCT_ID values.
You can use LEN function in SQL to check the length of PRODUCT_ID and see if there are any discrepancies:SELECT distinct PRODUCT_ID, LEN(PRODUCT_ID) AS Length
FROM [XXX-XX-XXXX].[PRODUCTS];
If your requirement is solved, please make THIS ANSWER a SOLUTION ✔️ and help other users find the solution quickly. Please hit the LIKE 👍 button if this comment helps you.
Hi, aditya_ghui
Thanks for the quick reply from [audreygerred]
You can try the following SQL query to ensure that you get unique PRODUCT_IDs by removing any hidden spaces or differences in case:
SELECT DISTINCT
TRIM(UPPER(PRODUCT_ID)) AS PRODUCT_ID
FROM
[XXX-XX-XXXX].[PRODUCTS];
You can also create a calculated column in Power BI using DAX to remove duplicates within your report:
DistinctProductIDs = DISTINCT(Products[PRODUCT_ID])
Best Regards,
Muhammad Yousaf
If this post helps, then please consider "Accept it as the solution" to help the other members find it more quickly.