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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
busy86
Frequent Visitor

DateDIFF Workign Days Calculation

Hi there,

 

I used this thread here: https://community.powerbi.com/t5/Desktop/Calculate-Date-and-Time-difference-considering-the-weekends...

 

To build a report that calculates working days between ticket create and resolved dates to product mean time to resolve, however I now need to include open tickets in the solution. The problem is, open tickets do not yet have a resolved date, so the last day start time is in 1899 and it skews the stats, as the MTTR is negative.

 

I've tried doing an IF to switch the last day start to the current day where the ticket is closed:

Cal_LastDayStartTime = if('fpscdb002_ws_003 incident'[Cal_Closed]="Yes", DATE (YEAR ('fpscdb002_ws_003 incident'[resolved_date]), MONTH('fpscdb002_ws_003 incident'[resolved_date]), DAY('fpscdb002_ws_003 incident'[resolved_date])) & " 08:30", DATE (YEAR(TODAY()), MONTH (TODAY()), DAY(TODAY()) & " 08:30"))

 

but I get  "expressions that yield variant data type cannot be used to define calculated columns" - all seemingly related to the IF statement.

 

Please help!

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous,

Current power bi not allow you direct calculate between different data types(date/text), you can add format function to convert your date values to fix this issue.

Cal_LastDayStartTime =
IF (
    'fpscdb002_ws_003 incident'[Cal_Closed] = "Yes",
    FORMAT (
        DATE ( YEAR ( 'fpscdb002_ws_003 incident'[resolved_date] ), MONTH ( 'fpscdb002_ws_003 incident'[resolved_date] ), DAY ( 'fpscdb002_ws_003 incident'[resolved_date] ) ),
        "General Date"
    ) & " 08:30",
    FORMAT (
        DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), DAY ( TODAY () ) ),
        "General Date"
    ) & " 08:30"
)

Best Regards,

Jack

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.