Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have converted the time into [h]:mm format; however, the time duration is currently in string format. I need to find the average of the Time A-C column. I tried to change data type but it does not change and shows error. Help me to find the solution of this question.
Solved! Go to Solution.
Hi @Manav-Shah
You can modify the measure as follows.
average =
VAR _sum = SUM(Sheet2[h]) * 60 + SUM(Sheet2[m])
VAR _count = COUNTROWS(Sheet2)
VAR _averageSecond = DIVIDE(_sum, _count) * 60
VAR _NumberOfHours = QUOTIENT(_averageSecond, 3600)
VAR _NumberOfMinutes = QUOTIENT( MOD(_averageSecond, 3600), 60)
RETURN
FORMAT(_NumberOfHours, "[h]") & ":" & FORMAT(_NumberOfMinutes, "[m]")
Best Regards,
Community Support Team _Yuliax
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Manav-Shah
Here is my testing.
1. Create two calculated column as follow.
h =
VAR TimeSecond = Sheet2[Time] * 86400
VAR NumberOfHour = QUOTIENT(TimeSecond, 3600)
VAR NumberOfMinutes = QUOTIENT( MOD(TimeSecond, 3600), 60)
RETURN
FORMAT(NumberOfHour, "[h]")
m =
VAR TimeSecond = Sheet2[Time] * 86400
VAR NumberOfHour = QUOTIENT(TimeSecond, 3600)
VAR NumberOfMinutes = QUOTIENT( MOD(TimeSecond, 3600), 60)
RETURN
FORMAT(NumberOfMinutes, "mm")
2. Create a measure as follow
average =
VAR _sum = SUM(Sheet2[h]) * 60 + SUM(Sheet2[m])
VAR _count = COUNTROWS(Sheet2)
VAR _averageSecond = DIVIDE(_sum, _count) * 60
VAR _NumberOfHours = QUOTIENT(_averageSecond, 3600)
VAR _NumberOfMinutes = QUOTIENT( MOD(_averageSecond, 3600), 60)
RETURN
FORMAT(_NumberOfHours, "[h]") & ":" & FORMAT(_NumberOfMinutes, "mm")
Is this the result you expect?
Best Regards,
Community Support Team _Yuliax
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
This result not match my actual result. The actual average-timing is 90:36.
Hi @Manav-Shah
You can modify the measure as follows.
average =
VAR _sum = SUM(Sheet2[h]) * 60 + SUM(Sheet2[m])
VAR _count = COUNTROWS(Sheet2)
VAR _averageSecond = DIVIDE(_sum, _count) * 60
VAR _NumberOfHours = QUOTIENT(_averageSecond, 3600)
VAR _NumberOfMinutes = QUOTIENT( MOD(_averageSecond, 3600), 60)
RETURN
FORMAT(_NumberOfHours, "[h]") & ":" & FORMAT(_NumberOfMinutes, "[m]")
Best Regards,
Community Support Team _Yuliax
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
I have two data sheet in excel,
First sheet is below
and second data sheet
These two data sheet I have in excel and I have to convert below data calculation in Power BI from these two data sheet.
In Power BI, you can calculate the average of time values in the "[h]:mm" format using DAX (Data Analysis Expressions). Here are the steps to achieve this:
Assuming your time values are in a column named "Time" in the format "[h]:mm", follow these steps:
Convert Text to Time:
TimeConverted = TIMEVALUE('YourTable'[Time])
Replace 'YourTable' with the actual name of your table.
Calculate Average:
AverageTime = AVERAGE('YourTable'[TimeConverted])
Replace 'YourTable' with the actual name of your table.
This formula will give you the average time in decimal format. If you want to display it in the "[h]:mm" format, you can use the FORMAT function:
AverageTimeFormatted = FORMAT(AVERAGE('YourTable'[TimeConverted]), "[h]:mm")
Now, you can use the "AverageTimeFormatted" column in your Power BI report to display the average time in the desired format.
Make sure to replace 'YourTable' with the actual name of your table and adjust column names accordingly based on your dataset.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
It still showing error.
It seems like there might be issues with the data in your columns. The error "Cannot convert value '89:02' of type text to type date" indicates that there might be some values in your columns that are not in a valid time format.
To address this issue, you can follow these steps:
Check Data Quality:
Handle Invalid Values:
Ensure Consistency:
Here is an example of how you might handle invalid values and ensure consistency:
TimeColumn = IF(ISERROR(TIMEVALUE([YourTextColumn])), BLANK(), TIMEVALUE([YourTextColumn]))
Replace [YourTextColumn] with the actual column name that contains your time values in text format. This formula uses the TIMEVALUE function to attempt conversion, and if it encounters an error (indicating an invalid time format), it returns BLANK().
Once you've handled potential issues in your data, you should be able to calculate the average without encountering conversion errors.
If you still face issues or if you have specific examples of data causing problems, feel free to provide more details, and I can help you further troubleshoot the problem.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
I have time data in string format, I tried the Timevalues and Format function but it shows same error.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
9 |