Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi, 
I have two tables and Calendar_table
Table 1
| Project | Site | Start date | End date | Duration | 
| 1122 | 12 | 01.05.2023 | 10.07.2023 | 10 | 
| 1122 | 12 | 11.07.2023 | 02.09.2023 | 8 | 
| 1122 | 12 | 03.09.2023 | 13.12.2023 | 14 | 
| 1133 | 13 | 02.02.2023 | 02.06.2023 | 17 | 
| 1133 | 13 | 03.06.2023 | 12.09.2023 | 14 | 
| 1133 | 13 | 13.09.2023 | 15.11.2023 | 9 | 
| 1133 | 14 | 01.04.2023 | 25.06.2023 | 12 | 
| 1133 | 14 | 26.06.2023 | 05.10.2023 | 14 | 
| 1133 | 14 | 06.10.2023 | 13.12.2023 | 10 | 
Table 2
| Person | Project | Site | Start date appointment site | End dateappointment site | 
| Name | 1122 | 12 | 01.05.2023 | 10.09.2023 | 
| Name | 1133 | 13 | 02.02.2023 | 13.09.2023 | 
| Name | 1133 | 14 | 01.04.2023 | 26.06.2023 | 
| Name2 | 1122 | 12 | 11.09.2023 | |
| Name2 | 1133 | 13 | 14.09.2023 | |
| Name2 | 1133 | 14 | 26.06.2023 | 
Table 2 has many-to-many connection with Table 1, where Table 2 ---> Table 1 (not both) by Site
I need mesure depens on Calendar_table - which returns actual Duration (period Start Date-End Date) and actual appointment Site for Person. 
For example, 
Choose in Calendar_table - March 2023
Name - Site 13 - returns 17
Name2 - Site 13 - returns null
Calendar_table - November 2023
Name - Site 13 - returns null
Name2 - Site 13 - returns 9
Solved! Go to Solution.
Hi @Anonymous ,
To calculate the actual Duration for each Person and Site based on the Calendar_table date selection, we can use DAX to:
Steps to Create the Measure
Here’s a DAX measure to compute the Actual Duration:
Actual Duration = 
VAR SelectedDate = MAX(Calendar_table[Date]) -- The selected date from the Calendar table
VAR AppointmentPeriod = 
    FILTER(
        Table2,
        Table2[Start date appointment site] <= SelectedDate &&
        (ISBLANK(Table2[End dateappointment site]) || Table2[End dateappointment site] >= SelectedDate)
    )
VAR ProjectPeriod = 
    FILTER(
        Table1,
        Table1[Start date] <= SelectedDate &&
        Table1[End date] >= SelectedDate
    )
VAR MatchingPeriods =
    FILTER(
        GENERATE(AppointmentPeriod, ProjectPeriod),
        Table2[Project] = Table1[Project] &&
        Table2[Site] = Table1[Site]
    )
RETURN
    SUMX(MatchingPeriods, Table1[Duration])
Expected Output
Best regards,
Hi @Anonymous ,
To calculate the actual Duration for each Person and Site based on the Calendar_table date selection, we can use DAX to:
Steps to Create the Measure
Here’s a DAX measure to compute the Actual Duration:
Actual Duration = 
VAR SelectedDate = MAX(Calendar_table[Date]) -- The selected date from the Calendar table
VAR AppointmentPeriod = 
    FILTER(
        Table2,
        Table2[Start date appointment site] <= SelectedDate &&
        (ISBLANK(Table2[End dateappointment site]) || Table2[End dateappointment site] >= SelectedDate)
    )
VAR ProjectPeriod = 
    FILTER(
        Table1,
        Table1[Start date] <= SelectedDate &&
        Table1[End date] >= SelectedDate
    )
VAR MatchingPeriods =
    FILTER(
        GENERATE(AppointmentPeriod, ProjectPeriod),
        Table2[Project] = Table1[Project] &&
        Table2[Site] = Table1[Site]
    )
RETURN
    SUMX(MatchingPeriods, Table1[Duration])
Expected Output
Best regards,
Thanks a lot! It's work!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
            | User | Count | 
|---|---|
| 8 | |
| 5 | |
| 5 | |
| 4 | |
| 3 | 
| User | Count | 
|---|---|
| 24 | |
| 11 | |
| 10 | |
| 9 | |
| 8 |