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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ghuiles
Advocate IV
Advocate IV

How to generate a list of filtered distinct rows (for a slicer)

Hello,

 

I have a column from a larger table. From this column i would like to have:

- the distinct values

- excluding blanks 

- and excluding lines that have strings containing several dashes (e.g. "---", "--", "----------", etc.)

 

We could imagine the column as follow (ignoring the other columns):

Customer A

Customer B

---

-------

Blank

Customer A

Customer B

 

I am struggling with it, and until now did not find a proper way to use DISTINCT with FILTER....

Does somebody has an answer?

Cheers. G,

1 ACCEPTED SOLUTION
Anonymous
Not applicable


@Seward12533 wrote:

This DAX will create a table of unique values without blanks.  New Table is on the modeling tab. 

 

Unique Customers Filtered  = CALCULATETABLE(VALUES('Customer'[Customer Name]),not(ISBLANK('Customer'[Customer Name]))&&'Customer'[Customer Name]<>"---"&&'Customer'[Customer Name]<>"-------")


 

Just add LEFT to @Seward12533 formula:

 

Unique Customers Filtered  = CALCULATETABLE(VALUES('Customer'[Customer Name]),not(ISBLANK('Customer'[Customer Name]))&&LEFT('Customer'[Customer Name],1)<>"-"

View solution in original post

6 REPLIES 6
Seward12533
Solution Sage
Solution Sage

This DAX will create a table of unique values without blanks.  New Table is on the modeling tab. 

 

Unique Customers Filtered  = CALCULATETABLE(VALUES('Customer'[Customer Name]),not(ISBLANK('Customer'[Customer Name]))&&'Customer'[Customer Name]<>"---"&&'Customer'[Customer Name]<>"-------")

Anonymous
Not applicable


@Seward12533 wrote:

This DAX will create a table of unique values without blanks.  New Table is on the modeling tab. 

 

Unique Customers Filtered  = CALCULATETABLE(VALUES('Customer'[Customer Name]),not(ISBLANK('Customer'[Customer Name]))&&'Customer'[Customer Name]<>"---"&&'Customer'[Customer Name]<>"-------")


 

Just add LEFT to @Seward12533 formula:

 

Unique Customers Filtered  = CALCULATETABLE(VALUES('Customer'[Customer Name]),not(ISBLANK('Customer'[Customer Name]))&&LEFT('Customer'[Customer Name],1)<>"-"

Excellent! Thank you guys! 🙂

 

@Seward12533 Thanks!

@Anonymous Your solution works! Thanks!!! 🙂

solvisig
Advocate III
Advocate III

Hi Ghuiles,

Have you tried using the contains filter to remove the dash columns?

contains filter

and remove empty to remove the blanks:
removeempty


Just go into edit query and press the down error next to the column you would like to edit and there you will find the 'Remove Empty' function and Text filter to apply the contains dash filter.

Whao! Thanks @solvisig and @Seward12533 for your very quick answer!

@solvisig: i know what you mean, but unfortuntely i have to do it with DAX. Sorry i did not mentioned it earlier

 

@Seward12533: your solution looks promising, but i would need a way to catch this "--" string flexibely, as the number of such strings may vary (from two to a lot...). Any clue on how i could do it? I tried before with the function SEARCH, but it did not work.

 

Best regards. G.

I'm sure there is a fancier way to get around this in DAX but a quick and dirty way would be to add a column to test to see if Customer contains "-" and then filter on that column. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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