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
Anonymous
Not applicable

Create new table with distinct values and filters

I want to create a new table that contain a distinct value of SKU. However, when I try with filters, the distinct values can not comply with the DAX code so I don't know where should I put the distinct code. Here is my code, basically I need the distinct values of SKU along with the brands and their descriptions. I also want to apply the filters where the SKU code must not start with "S", "O" and list of SKU with condition (brand<>blank()&&left(sku,1)="C-")

 

FILTER(SUMMARIZECOLUMNS(ItemPackage[SKU],ItemPackage[PackageDescription],ItemPackage[Brand Name]),LEFT(ItemPackage[SKU],1)<>"S"&&LEFT(ItemPackage[SKU],1)<>"O"&&(ItemPackage[Brand Name]<>BLANK()&&LEFT(ItemPackage[SKU],1)="C")))

 

8 REPLIES 8
amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Anonymous
Not applicable

I sent you a private message. Or do you have any suggestion for me to give you the sample data? Seems like I can't paste the data here

amitchandak
Super User
Super User

@Anonymous , Try like


SUMMARIZE(FILTER(ItemPackage, not(LEFT(ItemPackage[SKU],1) in {"S","O","C"}) && not(isblank(ItemPackage[SKU]))), ItemPackage[SKU],ItemPackage[PackageDescription],ItemPackage[Brand Name])

 

or

 

SUMMARIZE(FILTER(ItemPackage, not(LEFT(ItemPackage[SKU],1) in {"S","O","C"}) && not(isblank(ItemPackage[SKU]))), ItemPackage[SKU],ItemPackage[PackageDescription]."Brand Name",max(ItemPackage[Brand Name]))

Anonymous
Not applicable

Thank you for taking your time to answer my question but this will make the SKU appear twice/more than once (not distinct) if the descriptions are not same. I need the SKU to be distinct regardless of the description.

@Anonymous , try like

SUMMARIZE(FILTER(ItemPackage, not(LEFT(ItemPackage[SKU],1) in {"S","O","C"}) && not(isblank(ItemPackage[SKU]))), ItemPackage[SKU],"PackageDescription" ,max(ItemPackage[PackageDescription]),"Brand Name",max(ItemPackage[Brand Name]))

Anonymous
Not applicable

What if I need to add more condition that check 2 fields? The SKU that starts with C and brand that is blank, need to be removed. The additional condition is the same as this LEFT(ItemPackage[SKU],1)=2 && ItemPackage[Brand Name]<>BLANK() . I tried this code but turns out it delete all of the rows that starts with other codes. 

 

SUMMARIZE(FILTER(ItemPackage, not(LEFT(ItemPackage[SKU],1) in {"S","O","P","M"}) && (LEFT(ItemPackage[SKU],1) in {"C"} && ItemPackage[Brand Name]<>BLANK())&& NOT(CONTAINSSTRING(ItemPackage[PackageDescription],"Do not use")) && NOT(CONTAINSSTRING(ItemPackage[PackageDescription],"OBSOLETE"))), ItemPackage[SKU],"PackageDescription" ,max(ItemPackage[PackageDescription]),"Brand Name",max(ItemPackage[Brand Name]))

@Anonymous , Seem fine. Try with one change

SUMMARIZE(FILTER(ItemPackage, not(LEFT(ItemPackage[SKU],1) in {"S","O","P","M"}) && (LEFT(ItemPackage[SKU],1) in {"C"} && not(isblank(ItemPackage[Brand Name])))&& NOT(CONTAINSSTRING(ItemPackage[PackageDescription],"Do not use")) && NOT(CONTAINSSTRING(ItemPackage[PackageDescription],"OBSOLETE"))), ItemPackage[SKU],"PackageDescription" ,max(ItemPackage[PackageDescription]),"Brand Name",max(ItemPackage[Brand Name]))

 

Remove filter one by one check which one is causing this

Anonymous
Not applicable

Still. I'm supposed to have more than 9000 rows and now only left with 1000 rows. Other codes are removed like SKU that starts with B

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.

Top Solution Authors