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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Hesham121
Regular Visitor

DAX Sum Values based on 3 different tables criteria

Hello Dears,

 

I've the below data set and I want to create a measure that calculate total number of trips with the below critera:

 

- Sum 'DR_DUTIES'[# Of Trips]

If

'ROSTER DATABASE'[DATE] = 'APP_TT'[Date]

&

'APP_TT'[Applied TT] = 'DR_DUTIES'[TimeTable]

'DR_DUTIES'[Driving Duty] = 'ROSTER DATABASE'[Activity]

 

I need to SUM the # Of Trips and total Driving Hours per Employee based on Date, Activity, and Applied Timetable

 

1- DR_DUTIES Table:

 

Driving DutyTimeTable# Of TripsDriving Hours
M-01Ph3BTTR_TH_GIZA66:52:57 AM
M-02Ph3BTTR_TH_GIZA55:47:14 AM
E-01Ph3BTTR_TH_GIZA55:30:41 AM
E-02Ph3BTTR_TH_GIZA66:47:20 AM
M-01Ph3A_WE_LUXOR54:18:32 AM
M-02Ph3A_WE_LUXOR65:13:27 AM
E-01Ph3A_WE_LUXOR65:13:27 AM
E-02Ph3A_WE_LUXOR65:13:27 AM
M-01Ph3BTTR_WD_ASWAN55:29:32 AM
M-02Ph3BTTR_WD_ASWAN65:04:59 AM
E-01Ph3BTTR_WD_ASWAN66:34:00 AM
E-02Ph3BTTR_WD_ASWAN65:05:30 AM

 

2- Applied TT Table:

 

DateApplied TT
01-Jun-23Ph3BTTR_TH_GIZA
02-Jun-23Ph3BTTR_TH_GIZA
03-Jun-23Ph3BTTR_WD_ASWAN
04-Jun-23Ph3A_WE_LUXOR
05-Jun-23Ph3BTTR_TH_GIZA
06-Jun-23Ph3A_WE_LUXOR
07-Jun-23Ph3BTTR_WD_ASWAN
08-Jun-23Ph3BTTR_WD_ASWAN

 

3- ROSTER DATABASE Table:

 

CODEDateActivity
Emp0101-Jun-23E-02
Emp0102-Jun-23E-01
Emp0103-Jun-23M-02
Emp0104-Jun-23M-01
Emp0105-Jun-23E-02
Emp0106-Jun-23E-01
Emp0107-Jun-23M-02
Emp0108-Jun-23M-01

 

Expected Results should be

 

45 Trips and 43:32 Driving hours during the period 1-Jun-23 to 8-Jun-23 for the Emp01

1 ACCEPTED SOLUTION

Here is one possible implementation.  Note that my result differs from yours.

 

lbendlin_0-1708266287119.png

 

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

That seems to be straightforward, you should be able to use data model and TREATAS or USERELATIONSHIP to handle that.  What have you tried and where are you stuck?

 

lbendlin_1-1708262485412.png

 

I've tried to connect the data model, but it wasn't able to get the correct results and I don't why... maybe there are a problem with the data modeling, Can you suggest the best connection between tables please?

Hesham121_0-1708261867548.png

 

Here is one possible implementation.  Note that my result differs from yours.

 

lbendlin_0-1708266287119.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.