Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
Please try this calculated column, and this can easily reach your requirement:
Total Hour = DATEDIFF('Table'[Col 1],'Table'[Col 2],SECOND)/3600
The result shows:
If my answer has solved your issue, please mark it as a solution for others to see.
Thanks!
Best Regards,
Giotto Zhi
Hi,
Try this calculated column formula
=Data[Col2]-Data[Col1]
Format this column as Date/Time.
Hope this helps.
Hi,
This calculated column formula works
=DATEDIFF([Col1],[Col2],MINUTE)/60
Hope this helps.
Do this in Power Query. Your model will perform better, and it is a simple formula.
Add a new Custom Column in Power Query and add this formula, then round as desired.
= Duration.TotalHours([Col1] - [Col2])
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHi @edhans
Thanks for the replay but I have done some calculation for getting (calculated column) date/time for the table. so i need dax to achieve this in front side.
To create column in query editor is difficult for me.
is there any way to achieve in dax?
@Ashish_Mathur did it in DAX, which will work better for you since your dates were created in DAX. Consider using Power query in the future for all columns though. It is just good practice. The problem is calculated columns are very "excel-like" and Excel users jump on them, but that is not a good long term practice, especially for large models.
In general, try to avoid calculated columns. There are times to use them, but it is rare. Getting data out of the source system, creating columns in Power Query, or DAX Measures are usually preferred to calculated columns. See these references:
Calculated Columns vs Measures in DAX
Calculated Columns and Measures in DAX
Storage differences between calculated columns and calculated tables
Creating a Dynamic Date Table in Power Query
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI Reporting@Ashish_Mathur @edhans @Greg_Deckler
i used
datediff =datediff(startate,enddate, hours)
@Ashish_Mathur i tried this too
=DATEDIFF([Col1],[Col2],MINUTE)/60
i am getting 0
is there any problem in the format?
@sathyaramesh are your columns really dates and times? They must be for this to work. They cannot be text that looks like it. That might be why you are getting zero. Check out this CONVERT() function in DAX and see if that helps.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI Reportingdatediff =datediff(startate,enddate, HOUR)
Not hours, make sure that is correct.
Yep, works
Hi @Greg_Deckler @edhans @Ashish_Mathur
Sorry for my mistake. I made some mistake in calculated column.(I used both date as (start date time) for finding difference).
i think its working fine. Thank you so much for all your replay
Please mark the one that finally nailed it @sathyaramesh as the solution so the thread will be solved and others can see the answer easily
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHi,
Mine is a calculated column formula - not a measure.
Hi,
Share the link from where i can download your PBI file.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
146 | |
108 | |
106 | |
90 | |
62 |