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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sovereignauto
Helper III
Helper III

Splitting Datediff with summary table

Good Morning, 

 

I have followed some of the guides on here to split dates by month.

 

As per the below: 

 

Util_summary = SUMMARIZE(filter(CROSSJOIN(FMS_UtilStatus_Changes,'Date'),'Date'[FullDateAlternateKey]>=(FMS_UtilStatus_Changes[crimson_startdate].[Date]) && 'Date'[FullDateAlternateKey]<=(FMS_UtilStatus_Changes[crimson_enddate].[Date])),FMS_UtilStatus_Changes[crimson_countasname],FMS_UtilStatus_Changes[crimson_vehicle],[Month-Year],[MonthSort],"Hours", (DATEDIFF(Min(FMS_UtilStatus_Changes[crimson_startdate]),Max(FMS_UtilStatus_Changes[crimson_enddate]),hour)))
 
But the total is wrong, the raw data shows the below: so a total of 696.68
 
 Start DateEnd Datecalculated Date StartCalculated date EndTime on Status (hours)
10/03/2022 13:0122/04/2022 11:3610/03/2022 13:0131/03/2022 00:00490.97
03/03/2022 11:2809/03/2022 13:4203/03/2022 11:2809/03/2022 13:42146.24
03/03/2022 11:2803/03/2022 11:2803/03/2022 11:2803/03/2022 11:280.00
11/02/2022 16:5903/03/2022 11:2801/03/2022 00:0003/03/2022 11:2859.47
 
 
The summary table shows:
 
Capture.PNG
 
Hope the above makes sense and any help would be much appreciated
1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @sovereignauto ,

According to your description, I create a sample, the result "1199" should be the datediff of the minimum startdate and the maxmum enddate in the table derived from the formula below. As the Util_summary only return one row, it regardless of the start date and end date in each row, only the maximum and minimum values ​​of the entire table are selected for comparison.

 

FILTER (
    CROSSJOIN ( FMS_UtilStatus_Changes, 'Date' ),
    'Date'[FullDateAlternateKey] >= ( FMS_UtilStatus_Changes[crimson_startdate].[Date] )
        && 'Date'[FullDateAlternateKey] <= ( FMS_UtilStatus_Changes[crimson_enddate].[Date] )
)

 

My solution is to add a 'Date'[FullDateAlternateKey] column in the summary table, modify the formula like this:

 

Util_summary =
SUMMARIZE (
    FILTER (
        CROSSJOIN ( FMS_UtilStatus_Changes, 'Date' ),
        'Date'[FullDateAlternateKey] >= ( FMS_UtilStatus_Changes[crimson_startdate].[Date] )
            && 'Date'[FullDateAlternateKey] <= ( FMS_UtilStatus_Changes[crimson_enddate].[Date] )
    ),
    FMS_UtilStatus_Changes[crimson_countasname],
    FMS_UtilStatus_Changes[crimson_vehicle],
    [Month-Year],
    [MonthSort],
    'Date'[FullDateAlternateKey],
    "Hours",
        (
            DATEDIFF (
                MIN ( FMS_UtilStatus_Changes[crimson_startdate] ),
                MAX ( FMS_UtilStatus_Changes[crimson_enddate] ),
                HOUR
            )
        )
)

 

In the visual, select all columns except FullDateAlternateKey, the Hours get the correct result.

vkalyjmsft_0-1651214488887.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

1 REPLY 1
v-yanjiang-msft
Community Support
Community Support

Hi @sovereignauto ,

According to your description, I create a sample, the result "1199" should be the datediff of the minimum startdate and the maxmum enddate in the table derived from the formula below. As the Util_summary only return one row, it regardless of the start date and end date in each row, only the maximum and minimum values ​​of the entire table are selected for comparison.

 

FILTER (
    CROSSJOIN ( FMS_UtilStatus_Changes, 'Date' ),
    'Date'[FullDateAlternateKey] >= ( FMS_UtilStatus_Changes[crimson_startdate].[Date] )
        && 'Date'[FullDateAlternateKey] <= ( FMS_UtilStatus_Changes[crimson_enddate].[Date] )
)

 

My solution is to add a 'Date'[FullDateAlternateKey] column in the summary table, modify the formula like this:

 

Util_summary =
SUMMARIZE (
    FILTER (
        CROSSJOIN ( FMS_UtilStatus_Changes, 'Date' ),
        'Date'[FullDateAlternateKey] >= ( FMS_UtilStatus_Changes[crimson_startdate].[Date] )
            && 'Date'[FullDateAlternateKey] <= ( FMS_UtilStatus_Changes[crimson_enddate].[Date] )
    ),
    FMS_UtilStatus_Changes[crimson_countasname],
    FMS_UtilStatus_Changes[crimson_vehicle],
    [Month-Year],
    [MonthSort],
    'Date'[FullDateAlternateKey],
    "Hours",
        (
            DATEDIFF (
                MIN ( FMS_UtilStatus_Changes[crimson_startdate] ),
                MAX ( FMS_UtilStatus_Changes[crimson_enddate] ),
                HOUR
            )
        )
)

 

In the visual, select all columns except FullDateAlternateKey, the Hours get the correct result.

vkalyjmsft_0-1651214488887.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors