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
ngadiez
Helper II
Helper II

Filter rows query with condition of more than 1 column

I have a table where there is column 'Category' and 'Transaction Date'

 

I want to filter out some Category like shoes, wallet, tie and transaction date after 1 Jan 2017.

 

Is there any way to do this from Query?

I know I can do it from Page Filter or Report Filter in the report but I want to do it from Query.

 

so if Category is wallet and transaction after 1 Jan 2017, I don't want to see it.

But if the category is wallet but transaction before that I want to have it.

 

 Table.SelectRows(#"Filtered 2", each [Category] <> "Shoes" and [PlanCode] <> "Tie" and [TransactionDate]<= #date(2017, 1, 1))

 

but I know this is not correct.

 

Thank you for your help.

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

You were close:

 

let
    Source = Table1,
    #"Filtered Rows" = Table.SelectRows(Source, each not List.Contains({"shoes","wallet","tie"},[Category]) or [Transaction Date] <= #date(2017, 1, 1))
in
    #"Filtered Rows"

 

By the way: strange that you want to include 1/1/2017?

Specializing in Power Query Formula Language (M)

View solution in original post

6 REPLIES 6
MarcelBeug
Community Champion
Community Champion

You were close:

 

let
    Source = Table1,
    #"Filtered Rows" = Table.SelectRows(Source, each not List.Contains({"shoes","wallet","tie"},[Category]) or [Transaction Date] <= #date(2017, 1, 1))
in
    #"Filtered Rows"

 

By the way: strange that you want to include 1/1/2017?

Specializing in Power Query Formula Language (M)

I want to filter data as per below table,

 

TestCost 1Cost 2 TestCost 1Cost 2
A010 A010
B00 C100
C100 E2020
D00    
E2020    

 

                Input                                                                Output

 

IF Cost1= 0 & Cost2 = 0 then dont populate the row.

 

Any help will be appreciated

@MarcelBeug

 

Just a quick question.

Will it filter out date after 1 Jan 2017 for other categories as well?

Because I want to retain the transaction record for other categories.

 

The reason I want to filter out this 3 categories is because we don't want to track them anymore. 

 

It want to

exclude AND([Category](shoes,wallet,tie),[TransactionDate](>=1Jan2017))

No, it will just filter out if the date is after 1/1/2017 and the category is one of shoes, wallet, tie.

 

So in the example below only shoes is filtered out; wallet and tie are kept because these are <= 1/1/2017.

The others are kept because they are not one of shoes, wallet, tie.

 

 

Filter rows query with condition of more than 1 column.png

Specializing in Power Query Formula Language (M)

@MarcelBeug

 

Thank you so much.

You are awesome.

This is just a hypothetical case.

 

Thank you so much for your help.

 

You are really awesome.

Thanks a lot

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.