The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I need to create a DAX measure which calculates difference in hours between two timestamp columns in a table.
the date format for those columns is yyyy-mm-ddThh:mm:ss:00.000+0000 ex) 2022-05-03T16:35:00.000+0000.
I tried using DATEDIFF(column1,column2,hour) but it didn't work but threw an error.
I was able to get the result I want through the sql query below in databricks using unix_timestamp function
select (unix_timestamp(coumn1)-unix_timestamp(column2))/3600 as hourly_diff from table1.
Could anyone help with this query?
Thanks for any kind of help in advance!
Hi @yjk3140 - I spotted this community posing that suggested that Direct Query was not available for datetimestamps with milliseconds. Solved: Convert UNIX timestamp to DateTime using Direct Qu... - Microsoft Power BI Community. Is there anyway to change the Databricks table to include the Unix TimeStamp as columns without the need for the addition of the unix_timestamp() function in Power BI query?
Hi @yjk3140 - Should you please share some same data, the DAX measure formula, the error message that the measure threw. If possible could you create a PBIX file that replicates the error with anonymous data.
Hi @Daryl-Lynch-Bzy thanks for the response.
This is a screenshot of data for these two timestamp columns
and the DAX query I wrote is
Is there any solution to get the same result through DAX query in PowerBI?
Thank you for your help in advance!
Hi @yjk3140 are you using Direct Query connection? and what is the data source? It appears that Power BI Data Model does not understand how to convert the DATEDIFF function into Direct Query that you data can understand. Based on the SQL example you provided, you may have to switch to use a UNIX timefunction like this:
Hour Difference = DIVIDE ( Unixtimestamp1 - Unixtimestamp2 , 3600 )
Hi @Daryl-Lynch-Bzy , I'm connecting Direct Query to Databricks SQL Endpoint from PowerBI..
How can I get the Unixtimestmp using DAX? As the timestamps I have are not in the format..
really appreciate your help