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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
iamprajot
Responsive Resident
Responsive Resident

Incorrect M Code needs correction.

Hi

I am joining two Tables into one from SQL Server but the code results in an error, might needs correction as I tried to get an idea from the Internet.

 

let
Source1 = Sql.Database("Database_Name", "SubReporting"),
Reporting_Table1 = Source{[Schema="Reporting",Item="Table1"]}[Data],
#"YearToDate Filter" = Table.SelectRows(Reporting_Table1, each Date.IsInYearToDate([InvoiceApprovedDate])),
#"Filtered Entity" = Table.SelectRows(#"YearToDate Filter", each ([ColumnA] = "Condition1"))


Source2 = Sql.Database("Database_Name", "SubReporting"),
Reporting_Table2 = Source{[Schema="Reporting",Item="Table2"]}[Data],
#"YearToDate Filter" = Table.SelectRows(Reporting_Table2, each Date.IsInYearToDate([DeliveryDate])),
#"Filtered Column" = Table.SelectRows(#"YearToDate FIlter", each ([ColumnA] = "Condition1")),

#"Result"=Table.Combine({Source1,Source2})

 

in
#"Result"

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

Well, for one thing you are missing a comma:

 

let
Source1 = Sql.Database("Database_Name", "SubReporting"),
Reporting_Table1 = Source{[Schema="Reporting",Item="Table1"]}[Data],
#"YearToDate Filter" = Table.SelectRows(Reporting_Table1, each Date.IsInYearToDate([InvoiceApprovedDate])),
#"Filtered Entity" = Table.SelectRows(#"YearToDate Filter", each ([ColumnA] = "Condition1")),

Source2 = Sql.Database("Database_Name", "SubReporting"),
Reporting_Table2 = Source{[Schema="Reporting",Item="Table2"]}[Data],
#"YearToDate Filter1" = Table.SelectRows(Reporting_Table2, each Date.IsInYearToDate([DeliveryDate])),
#"Filtered Column" = Table.SelectRows(#"YearToDate Filter1", each ([ColumnA] = "Condition1")),
#"Result"=Table.Combine({#"Filtered Entity",#"Filtered Column"})
 
in
#"Result"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg, I used this code and changed the Table & Column names but it results in the same error which I was previously.

 

let

Source1 = Sql.Database("", ""),

Reporting_Table1 = Source1{[Schema="Reporting",Item="Table1"]}[Data],

#"YearToDate Filter1" = Table.SelectRows(Reporting_Table1 , each Date.IsInYearToDate([Date])),

#"Filtered1" = Table.SelectRows(#"YearToDate Filter1", each ([Column1] = "Value1")),

 

Source2 = Sql.Database("", ""),

Reporting_Table2 = Source{[Schema="Reporting",Item="Table2"]}[Data],

#"YearToDate Filter2" = Table.SelectRows(Reporting_Table2, each Date.IsInYearToDate([Date])),

#"Filtered2" = Table.SelectRows(#"YearToDate Filter2", each ([Column] = "Value1")),

 

#"Result"=Table.Combine({#"Filtered1",#"Filtered2"})

 

in

#"Result"

 

Errors

 

1.PNG2.PNG3.PNG

 

 

Thanks

Prajot

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.