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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
modxplus
Frequent Visitor

Merge Date/Time tables with ranges

Little stuck on this project here. 

I have two tables. One is a Hours Worked Table (shown at the top) and another is an Absence Table (shown second). 

Then you see the expected result at the bottom. 

Basically what i am trying to do is merge the hours worked table with the absence table to be able to account for the hours used while on the clock. The problem is the Absence table is in a range so i cant just join on dates since you see in the top example the manager entered the absence for 2 days. 

 

It is just the range that is throwing me off and hoping someone can help. 

Capture.PNG

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @modxplus ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create two calculated columns .

Absence hours = var a= LOOKUPVALUE('Absence Table'[End],'Absence Table'[Name],[Name])
var b=LOOKUPVALUE('Absence Table'[Start],'Absence Table'[Name],[Name])
return SWITCH(TRUE(),[Date]=DATEVALUE(b)&&[Date]<DATEVALUE(a),HOUR([End Date/Time]-b),[Date]>DATEVALUE(b)&&[Date]<DATEVALUE(a),[Total Hours Worked],[Date]=DATEVALUE(a)&&[Date]=DATEVALUE(b),HOUR(a-b),[Date]=DATEVALUE(a)&&[Date]>DATEVALUE(b),HOUR(a-[Start Date/Time]),0)
Absence Type = var a=LOOKUPVALUE('Absence Table'[Type],[Name],[Name])
return IF([Absence hours]<>0,a)

(3) We can create a table.

Table = SUMMARIZE('Hours Worked Table',[Name],[Date],[Total Hours Worked],'Hours Worked Table'[Absence hours],[Absence Type])

(4)Then the result is as follows.

vtangjiemsft_0-1682322033965.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

2 REPLIES 2
Adoraiswamy
Regular Visitor

I have two set of tables (Hour Start) (Hour End) that has data collected in every 30 minutes duration. Using Power Query How do I merge them to Hourly data.I have zero knowledge on DAX but exploring other transformation tools. Your help is highly appreciated.  Thanks

 

Adoraiswamy_1-1702209357164.png 

Adoraiswamy_2-1702209367794.png

 

 

 
 
 
 
 
 
 
Anonymous
Not applicable

Hi @modxplus ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create two calculated columns .

Absence hours = var a= LOOKUPVALUE('Absence Table'[End],'Absence Table'[Name],[Name])
var b=LOOKUPVALUE('Absence Table'[Start],'Absence Table'[Name],[Name])
return SWITCH(TRUE(),[Date]=DATEVALUE(b)&&[Date]<DATEVALUE(a),HOUR([End Date/Time]-b),[Date]>DATEVALUE(b)&&[Date]<DATEVALUE(a),[Total Hours Worked],[Date]=DATEVALUE(a)&&[Date]=DATEVALUE(b),HOUR(a-b),[Date]=DATEVALUE(a)&&[Date]>DATEVALUE(b),HOUR(a-[Start Date/Time]),0)
Absence Type = var a=LOOKUPVALUE('Absence Table'[Type],[Name],[Name])
return IF([Absence hours]<>0,a)

(3) We can create a table.

Table = SUMMARIZE('Hours Worked Table',[Name],[Date],[Total Hours Worked],'Hours Worked Table'[Absence hours],[Absence Type])

(4)Then the result is as follows.

vtangjiemsft_0-1682322033965.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.