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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
v-junyant-msft
Community Support
Community Support

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
v-junyant-msft
Community Support
Community Support

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
Memorable Member
Memorable Member

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

where sheet1.CreateDate <= Sheet2.MonthEnd

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.