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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
guilhem
Frequent Visitor

how to join tables

Hello,

 

I have the following tables I would like to make a new table as per follows

 

join.jpg

 

select 

  Issue ID

  Unit Name

  Cap

  Date

From

  Sheet1 join Sheet2, Sheet3

Where

  (Sheet3.Unit ID = Sheet2.Unit ID) and

  ((Sheet1 Date >= Sheet3.Date Start) and (Sheet1 Date <= Sheet3.Date End))

 

 

Assuming Sheet3 is 

Issue IDUnit IDDate StartDate End
1101/11/201603/11/2016
2210/11/201614/11/2016
3125/11/201626/11/2016

 

Sheet 2 is

Unit IDUnit NameCap
1a10
2b20
3c30
4d40
5c50

 

and Sheet 1 are all the calendar days for the november 2016

 

I am hoping to get :

 

DateIssue IDUnit IDCap
01/11/20161a10
02/11/20161a10
03/11/20161a10
10/11/20162b20
11/11/20162b20
12/11/20162b20
13/11/20162b20
14/11/20162b20
25/11/20163c30
26/11/20163c30

 

Anyone can help ? 

 

Thanks ... 

1 ACCEPTED SOLUTION

I finally got the solution ...

 

Make a new table ...

Table = Filter( Crossjoin ( table A, TableB ), cond1&&cond2&&cond3....)

 

 

And it works ... 

 

View solution in original post

5 REPLIES 5
dkay84_PowerBI
Microsoft Employee
Microsoft Employee

 

My approach may not be the best, but here goes:

 

I would start with a merge as new query operation within the query editor.

 

You can perform all the select aspects after the merge (i.e. removing columns).

 

You join sheet2 and sheet3 on Unit ID, choosing the appropriate type of join.

 

Once you have this new merged query, merge it (as new query) with the sheet1 table using DateStart and Date as the fields, and choose the appropriate join type to return all rows from the fact table with only the matching rows from the date table.

 

Repeat this process, using the original merged query, but use the DateEnd field.

 

Append the two final merged tables (date start and date end).

 

Remove the columns you don't need.

sorry ... i am not too sure what you are telling me to do there ... 

 

My knowldge of power bi is too low...

 

Could you be more precise may be ?

 

Rgds

This is all done in the query editor.  Are you familiar with this part of Power BI (Get and Transform, formerly Power Query, in Excel)?

I finally got the solution ...

 

Make a new table ...

Table = Filter( Crossjoin ( table A, TableB ), cond1&&cond2&&cond3....)

 

 

And it works ... 

 

guilhem
Frequent Visitor

I have writen the sql query ...

 

SELECT
`a`.`Date` AS `Date`,
`b`.`UnitID` AS `UnitID`,
`b`.`IssueID` AS `IssueID`
FROM
(`sheet1` `a`
JOIN `Sheet3` `b`)
WHERE
((`a`.`Date` >= `b`.`Date Start`)
AND (`a`.`Date` <= `b`.`Date End`))

 

I just need this in Power BI language 😞

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.