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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Vidhyashree153
New Member

Inner join with condition

Hello,
I have a problem about joining two tables with condition.
Please help.

Eg.
Table : Sheet1
field : Defectnumber, CreateDate

Table : Sheet2
field : MonthStart, MonthEnd

 

i have to join both the sheets and get the inventory data of defects


with condition likes this :
Sheet1 inner join Sheet2
where sheet1.CreateDate <= Sheet2.MonthEnd

 

Below screenshot is from Tableau is there any way i can replicate this in PowerBI

Vidhyashree153_0-1725877221467.png

 


Please help me


Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Vidhyashree153 ,

You can try this way:
Here is my sample data:

vjunyantmsft_0-1725935725250.png

vjunyantmsft_1-1725935733911.png

Use this M code to create a Blank Query:

vjunyantmsft_2-1725935779671.png

let
    FindDefectnumber = (MonthStart as date, MonthEnd as date) =>
    let
        FilteredRows = Table.SelectRows(Sheet1, each [CreateDate] >= MonthStart and [CreateDate] <= MonthEnd),
        DefectnumberCol = Table.Column(FilteredRows, "Defectnumber")
    in
        DefectnumberCol
in
    FindDefectnumber

vjunyantmsft_3-1725935806256.png

Then back to Sheet2 and create a Invoke Custom Function:

vjunyantmsft_4-1725935911144.png

vjunyantmsft_5-1725935922408.png
Expand columns:

vjunyantmsft_6-1725935994136.png

Output:

vjunyantmsft_7-1725936009958.png


Then you can inner join Sheet1 and Sheet2 with column Defectnumber and Related Number:

vjunyantmsft_8-1725936150083.png

 

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Vidhyashree153 ,

You can try this way:
Here is my sample data:

vjunyantmsft_0-1725935725250.png

vjunyantmsft_1-1725935733911.png

Use this M code to create a Blank Query:

vjunyantmsft_2-1725935779671.png

let
    FindDefectnumber = (MonthStart as date, MonthEnd as date) =>
    let
        FilteredRows = Table.SelectRows(Sheet1, each [CreateDate] >= MonthStart and [CreateDate] <= MonthEnd),
        DefectnumberCol = Table.Column(FilteredRows, "Defectnumber")
    in
        DefectnumberCol
in
    FindDefectnumber

vjunyantmsft_3-1725935806256.png

Then back to Sheet2 and create a Invoke Custom Function:

vjunyantmsft_4-1725935911144.png

vjunyantmsft_5-1725935922408.png
Expand columns:

vjunyantmsft_6-1725935994136.png

Output:

vjunyantmsft_7-1725936009958.png


Then you can inner join Sheet1 and Sheet2 with column Defectnumber and Related Number:

vjunyantmsft_8-1725936150083.png

 

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Omid_Motamedise
Super User
Super User

Add a new column and sued Table.SelectRows to filter the rows on sheet 2 with the below condition

where sheet1.CreateDate <= Sheet2.MonthEnd


If my answer helped solve your issue, please consider marking it as the accepted solution.
Vidhyashree153
New Member

There are no common columns between both sheets so i need to add condition for the join itself

You can first apply the inner join using the merge queries in power query and then create an additional column to filter it out on that basis.
if [CreateDate] >= [MonthStart] and [CreateDate] <= [MonthEnd] then "Include" else "Exclude"


You can first apply the inner join using the merge queries in power query and then create an additional column to filter it out on that basis.
if [CreateDate] >= [MonthStart] and [CreateDate] <= [MonthEnd] then "Include" else "Exclude"


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors