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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Datediff function seconds and minutes

Hi, 

 

When I calculate a datediff in hours I haven't any problem:

*Countdown (hours) = IF(ISBLANK(RELATED(mysql_mail_log[created])),DATEDIFF(mysql_reports[*NU],mysql_reports[first_report_expected],HOUR))
svanwetswinkel_0-1651781854227.png

 

When I try to calculate the datediff in minutes or seconds, I receive the mesage 'Can't display the visual -> OLE DB or EDBC error: [Expression.Error] We couldn't fold the expression to the data source. 
 
*Countdown (minutes) = IF(ISBLANK(RELATED(mysql_mail_log[created])),DATEDIFF(mysql_reports[*NU],mysql_reports[first_report_expected],MINUTE))
 
svanwetswinkel_1-1651781943368.png

 

 Anyone knows what is wrong?
 
I'm using SQL direct query data. 
 

 

6 REPLIES 6
tamerj1
Super User
Super User

@Anonymous 

Strange that the HOUR works! Creating time related calculated columns is not allowed in direct query. You have to create measures only

Anonymous
Not applicable

how I calculate 'hh:mm' or decimal hours with only measurement and without column? I want a value for every row without a calculation like sum, average, ...

Hi @Anonymous 
This might require further formatting

Countdown (minutes) =
VAR TimeDifference =
    SUMX (
        mysql_reports,
        IF (
            ISBLANK ( RELATED ( mysql_mail_log[created] ) ),
            DATEDIFF ( mysql_reports[*NU], mysql_reports[first_report_expected], MINUTE )
        )
    )
RETURN
    QUOTIENT ( TimeDifference, 60 ) & ":"
        & MOD ( TimeDifference, 60 )

Would be great if you can provide sample file

Anonymous
Not applicable

I don't succeed 😞

Is it possible to mail you the file? 

I hope you can give me the solution. 

@Anonymous 
I sent my email in a private message

@Anonymous 
Even more simple is just to substract and select "Short Time" data type manually.

Countdown (minutes) =
SUMX (
    mysql_reports,
    IF (
        ISBLANK ( RELATED ( mysql_mail_log[created] ) ),
        mysql_reports[first_report_expected] - mysql_reports[*NU]
    )
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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