Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
jzhao
Frequent Visitor

values and distinc function input

I want to retrieve unique rows from three different columns in three different tables. Then, I want to filter out rows that contain `*` or are blank. The following code provides the desired result:

 

All projects =
FILTER(
    DISTINCT(
            UNION(
                VALUES('table1'[column 1 clean]),VALUES('table 2'[column2 clean])
                )
            ),
    IF([Cust_Po_num_Clean]<>BLANK()&&[Cust_Po_num_Clean]<>"0" && [Cust_Po_num_Clean]<>"#",TRUE(),FALSE())
    )
 
However, the following code generates an error:
All projects =
FILTER(
    Values(
            UNION(
                VALUES('table1'[column 1 clean]),VALUES('table 2'[column2 clean])
                )
            ),
    IF([Cust_Po_num_Clean]<>BLANK()&&[Cust_Po_num_Clean]<>"0" && [Cust_Po_num_Clean]<>"#",TRUE(),FALSE())
    )

What could be the reason for the error?

2 REPLIES 2
Anonymous
Not applicable

Hi @jzhao ,

The reason for the error in your second code is that you are using the VALUES function instead of the DISTINCT function to return a table of unique rows. The VALUES function returns a one-column table that contains the distinct values from the specified column, optionally ignoring any blank values. However, in your case, you are passing a table expression to the VALUES function, which is not a valid argument. The VALUES function expects a column reference as its input parameter.

The DISTINCT function, on the other hand, returns a table by removing duplicate rows from another table or expression. The DISTINCT function can take any table expression as its input parameter, and it will return a table with the same columns and only distinct rows.

Therefore, to fix your error, you need to replace the VALUES function with the DISTINCT function in your second code, as you did in your first code. This will ensure that you are passing a valid table expression to the FILTER function, and that you are getting a table of unique rows from three different columns in three different tables.

 

Solved: Find and Replace values either by a measure and or... - Microsoft Fabric Community

DISTINCT (table) function (DAX) - DAX | Microsoft Learn

powerbi - DAX Query to Get Distinct Items from Multiple Tables - Stack Overflow

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

some_bih
Super User
Super User

Hi @jzhao UNION function features: The two tables must have the same number of columns. In example column1 clean and column2 clean 

https://learn.microsoft.com/en-us/dax/union-function-dax?WT.mc_id=DP-MVP-4025372 

Did I answer your question? Kudos appreciated / accept solution!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.