Home

Joining two tables using different columns

%3CLINGO-SUB%20id%3D%22lingo-sub-644439%22%20slang%3D%22en-US%22%3ERe%3A%20Joining%20two%20tables%20using%20different%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-644439%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F347514%22%20target%3D%22_blank%22%3E%40Uncle_J%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20do%20that%20from%20user%20interface%20-%20query%20your%20A%20and%20DimDate%20tables%2C%20using%20Merge%20Queries%20left%20join%20them%20in%20new%20query%20or%20in%20query%20A%2C%20expand%20fields%20you%20need%20and%20filter%20result%20by%20date.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20you%20always%20may%20adjust%20generated%20M-script%20in%20advanced%20editor.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-638274%22%20slang%3D%22en-US%22%3EJoining%20two%20tables%20using%20different%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-638274%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20I%20have%20%22Office%20365%20Business%22%3C%2FP%3E%3CP%3EI%20have%20imported%20a%20table%20A%20containing%20the%20columns%20StartDate%20and%20EndDate%2C%20I%20have%20also%20created%20a%20%22DimDate%22%20table.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20now%20I%20want%20to%20do%20a%20%22SELECT%20*%20FROM%20A%20LEFT%20JOIN%20DimDate%20D%20ON%20D.Date%20%26gt%3B%3DA.StartDate%20AND%20D.Date%26lt%3B%3DA.EndDate%20%22%3CBR%20%2F%3Ein%20order%20to%20have%20a%20fine%20PowerPivot%20dataset.%3CBR%20%2F%3EBut%20SQL%20is%20long%20gone%20and%20replaced%20by%20M%2C%20and%20I'm%20lost!%3CBR%20%2F%3EAny%20tips%20%2F%20syntax%20suggestions%3F%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-638274%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analytics%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENeed%20Help%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Uncle_J
Occasional Visitor

Hi I have "Office 365 Business"

I have imported a table A containing the columns StartDate and EndDate, I have also created a "DimDate" table.

 

And now I want to do a "SELECT * FROM A LEFT JOIN DimDate D ON D.Date >=A.StartDate AND D.Date<=A.EndDate "
in order to have a fine PowerPivot dataset.
But SQL is long gone and replaced by M, and I'm lost!
Any tips / syntax suggestions?  

1 Reply

@Uncle_J ,

 

You may do that from user interface - query your A and DimDate tables, using Merge Queries left join them in new query or in query A, expand fields you need and filter result by date.

 

And you always may adjust generated M-script in advanced editor.

Related Conversations