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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
EaglesTony
Post Prodigy
Post Prodigy

How do I filter records based off column values in another table(similiar to "IN" for SQL)

Hi,

 

  I have tableA with a 4 records and a column named Sprint and need to use these values to filter on another table.

 

  tableB has a column named SprintName with similiar values, but I want to filter these records based on tableA.

 

  In SQL it is something like "WHERE tableA.Sprint IN (tableB.SprintName)".

 

Thank you.

2 ACCEPTED SOLUTIONS
slorin
Super User
Super User

Hi

Join with JoinKind.Inner

 

= Table.NestedJoin(TableA, {"Sprint"}, TableB, {"SprintName"}, "TableB", JoinKind.Inner)

Stéphane 

View solution in original post

= Table.AddColumn(#"Changed Type", "Custom", each (x) => Table.SelectRows(TableB, each [StartDate] <= x[CreateDate] and [EndDate] >= x[CreateDate]){0}[Increment])

Stéphane 

View solution in original post

9 REPLIES 9
slorin
Super User
Super User

There is never relationship between the two tables in Power Query.

You want a DAX Mesure ?

I dont' understand, 5/1/2023 = increment 2 not 3 

Stéphane

 

5/1/2023 is on TableA, so I want to lookup on TableB and since it is between 4/21/2023 -  5/1/2023 (and equals 5/1/2023), take the number '2' from TableB and make that a new column on TableA.

Hi

Add a new column on TableA 

(x) => Table.SelectRows(TableB, each [StartDate] <= x[CreateDate] and [EndDate] >= x[CreateDate]){0}[Increment]

 Stéphane

Is this M or DAX ?...

I have the following on TableA

= Table.AddColumn(#"Changed Type", "Custom", each (x) => Table.SelectRows(TableA, each [StartDate] <= x[CreateDate] and [EndDate] >= x[CreateDate]){0}[Increment])

 

However, it is adding the column without the "Increment" column, but says "Function"

= Table.AddColumn(#"Changed Type", "Custom", each (x) => Table.SelectRows(TableB, each [StartDate] <= x[CreateDate] and [EndDate] >= x[CreateDate]){0}[Increment])

Stéphane 

EaglesTony
Post Prodigy
Post Prodigy

hi,

  I have a slighltly different scenerio.

 

  TableA has multiple rows and each with a CreateDate column on it.

 

  TableB has multiple rows with date ranges on it with StartDate and EndDate columns on it and a column I need to put on TableA called Increment.

 

  If TableA has 5/1/2023 and TableB has the following:

 

Increment   StartDate       EndDate

1                  4/1/2023       4/20/2023

2                  4/21/2023     5/1/2023

3                  5/2/2023       5/20/2023

 

I want TableA to have the number 3 (from increment on TableA)

FYI: There is no relationship between the two tables.

slorin
Super User
Super User

Hi

Join with JoinKind.Inner

 

= Table.NestedJoin(TableA, {"Sprint"}, TableB, {"SprintName"}, "TableB", JoinKind.Inner)

Stéphane 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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