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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Calculate and display the sum of total hours rather than the count of each hour record

I have a table that looks like this:

Location | Affected System | Total Hours

USA        |  ERP                    | 45

Ireland    | ERP                     | 20

USA        | SAP                     | 12

Japan      | LCV                     | 23

 

Each Total Hours value represents how long a system has been down for in that location. I wish to display, using a bar chart, the total amount of hours the system has been down, not the count of each total hours record per location

 

Is there a way to do this within Power BI? I have searched it but my issue seems to be too specific. Any help would be appreciated. Thanks!

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

If you want to SUM the Total Hours by the System, create a measure

Measure  = CALCULATE(SUM(Table[Total Hours]), ALLEXCEPT(Table, Table[System]))

It's always better if you can provide sample data (thanks for that) and desired result.

View solution in original post

7 REPLIES 7
HotChilli
Super User
Super User

If you want to SUM the Total Hours by the System, create a measure

Measure  = CALCULATE(SUM(Table[Total Hours]), ALLEXCEPT(Table, Table[System]))

It's always better if you can provide sample data (thanks for that) and desired result.

Anonymous
Not applicable

Thank you @HotChilli ,

 

This seems to work except I have an error saying: "The function SUM cannot work with values of type String."

 

I'm aware that VALUE() converts strings to a number, but it doesn't seem to work for converting an entire column of type string to a number. Any idea what the correct syntax of this would be? 

 

Thanks again.

What's the data type on Hours? It should be a whole number

Anonymous
Not applicable

It's from a SharePoint list with type Short Text. My bad, should have made it a number from the start. Do you recommend changing the column data type or converting to a new type within the measure?

 

EDIT: I changed the column type to a number and it's still throwing the same error. Any ideas as to where I have gone wrong? Thanks

I don't know where the error is but we should be able to debug.

Create a simple measure :

SUM(Table[Total Hours])

and see if that works first

Anonymous
Not applicable

I solved the issue, in the datasheet view, the TotalHours column was considered a String. I went to Modelling > Data type and changed the type to a whole number. As you said before. 

 

Thanks for your help! Very helpful. 

ZunzunUOC
Resolver III
Resolver III

Hi @Anonymous , you need both x and y to draw a bar chart. Which are they? I just see total hours

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.