Forum Discussion

S_Sanchez's avatar
S_Sanchez
Frequent Visitor
6 years ago
Solved

DATEDIFF not working in Power BI Service

I have a report that uses DirectQuery to connect to an SQL Server DB.  In the report, there is a measure that uses the DATEDIFF function.  This measure will calculate correctly in Power BI Desktop.  ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi S_Sanchez,

    AFAIK, current power bi service does not support local DateTime, it will convert local DateTime values to UTC format. (NOW function will get local DateTime when you use on power bi desktop side, but it may get the wrong result when you calculate on service side)

    If this issue is related to NOW function, you can try to use UTCNOW function to instead:

    Count_LastX =
    SUMX (
        FILTER (
            transaction_history,
            DATEDIFF ( transaction_history[Transaction_datetime], UTCNOW (), MINUTE ) <= Minutes[Minutes Value]
        ),
        [Total Meals]
    )
    

    Regards,

    Xiaoxin Sheng