cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Albertvw Frequent Visitor
Frequent Visitor

Filter table based on other table

New to all this ...

 

How can I filter import of tableA from Access, where field [Month] is equal/less than Tableb[CurMonth], a field we manually update when new month's data is ready to load on BI?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Filter table based on other table

thanks @austinsense 🙂

 

filter equal is easiest done by merging with JoinKind.Inner as described in these articles:

http://www.thebiccountant.com/2015/08/18/use-timeline-or-slicers-to-filter-your-power-query-import/

http://www.thebiccountant.com/2015/08/21/want-to-filter-a-pivottable-based-on-an-external-range-or-l...

 

filter < is a bit different: There you have to use parameters. To do so you start filtering your table in the desired way by putting in a hardcoded value. After that you edit the resulting M-code and replace the hardcoded value by the parameter.

The parameter can be retrieved from a table by it's coordinates:

queryname[Columnname]{Rownumber-1}

 

So say your parameter sits in the first row the expression would be: Tableb[CurrMonth]{0}

Rownumber is zero because M starts to count with 0 (for the 1st row)

 

So this is how the parametrized filter would look like:

 

= Table.SelectRows(Source, each [Month] < Tableb[CurrMonth]{0})

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

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




View solution in original post

6 REPLIES 6
Bjoern Established Member
Established Member

Re: Filter table based on other table

Create a calculcated column which checks for the "size" of the month and compare. If comparison is true, parse "Yes", otherwise "No". Then use this help-column for filtering via filter pane or slicer.

austinsense Established Member
Established Member

Re: Filter table based on other table

@ImkeF do you have some query magic for this guy?

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂
Highlighted
Super User
Super User

Re: Filter table based on other table

thanks @austinsense 🙂

 

filter equal is easiest done by merging with JoinKind.Inner as described in these articles:

http://www.thebiccountant.com/2015/08/18/use-timeline-or-slicers-to-filter-your-power-query-import/

http://www.thebiccountant.com/2015/08/21/want-to-filter-a-pivottable-based-on-an-external-range-or-l...

 

filter < is a bit different: There you have to use parameters. To do so you start filtering your table in the desired way by putting in a hardcoded value. After that you edit the resulting M-code and replace the hardcoded value by the parameter.

The parameter can be retrieved from a table by it's coordinates:

queryname[Columnname]{Rownumber-1}

 

So say your parameter sits in the first row the expression would be: Tableb[CurrMonth]{0}

Rownumber is zero because M starts to count with 0 (for the 1st row)

 

So this is how the parametrized filter would look like:

 

= Table.SelectRows(Source, each [Month] < Tableb[CurrMonth]{0})

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

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




View solution in original post

Albertvw Frequent Visitor
Frequent Visitor

Re: Filter table based on other table

Thank you! The imported data table now only shows up to month specified in TableB[mnt]. But, the reports 'working of' this table still include later data, i.e. I though this would restrict all reports based on that table to be limited to that?

 

I.e. used:  #"Up to Month" = Table.SelectRows(_CSI, each [Month] <= DBmnt[Mnt]{0})

Super User
Super User

Re: Filter table based on other table

That's not the expected behaviour.

I know this is  stupid question (but I have no other idea): Are you sure that the following queries are actually referencing this query of did you develop them earlier by just copying the original query? Then you had to apply this filter there as well.

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

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




Albertvw Frequent Visitor
Frequent Visitor

Re: Filter table based on other table

Yes, my 'previous' filter was interfering ... now fixed and working. 

 

Thank you for your assistance - really appreciated!

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 287 members 3,410 guests
Please welcome our newest community members: