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
alexlopesBS
Frequent Visitor

Remove rows based on category column

Hello, guys. 

 

Need help with some ETL stuff.

 

I have a table that comes to me bringing the following data:

 StoreProduct Department Store CategoryValues
1AlphaA12345
1BetaA12345
2AlphaB12345
2BetaB12345
2CaosB12345
3AlphaC12345
3BetaC12345

 

I get this info from a cube that cotains data on all departments for every store, and put it on excel. I cannot do anything with the data before it comes to excel. 

 

I then add it to Power BI and do the ETL process to fix it up. 

 

However, the client is requesting that I filter out "dead" departments in each store category, because it is tainting the whole picture with bad numbers. 

 

How could I do something like this:

DELETE ROW WHERE [Store Category] = B AND [Product Department] IN ("Beta", "Caos")

with Power Query? I am trying to figure it out using the documentation, but I am having a lot of difficulty finding the basic functions for Power Query on the microsoft site.

 

 

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

The easiest way is to reformulate your selection criteria to select rows where [Store Category] <> "B" or ([Product Department] <> "Beta" and [Product Department] <> "Caos").

 

First select [Store Category] <> "B" to create base code:

 

Select not B.png

 

then adjust the generated code (in the red rectangle in the picture) to:

 

= Table.SelectRows(#"Changed Type", each [Store Category] <> "B" or ([Product Department] <> "Beta" and [Product Department] <> "Caos"))
Specializing in Power Query Formula Language (M)

View solution in original post

3 REPLIES 3
Dwivedi15
Frequent Visitor

This did filtering the table but when counting rows using measure, it is counting all the rows even those filtered out rows.

 

MarcelBeug
Community Champion
Community Champion

The easiest way is to reformulate your selection criteria to select rows where [Store Category] <> "B" or ([Product Department] <> "Beta" and [Product Department] <> "Caos").

 

First select [Store Category] <> "B" to create base code:

 

Select not B.png

 

then adjust the generated code (in the red rectangle in the picture) to:

 

= Table.SelectRows(#"Changed Type", each [Store Category] <> "B" or ([Product Department] <> "Beta" and [Product Department] <> "Caos"))
Specializing in Power Query Formula Language (M)

How do you delete the rows you don't want?

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