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

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.

Reply
Anonymous
Not applicable

Group codes and sum their values from a single text string

Hi,

 

I've got a text column with this format "Oper A - 8.5, Oper B - 3.0, Oper A - 2.5, Oper C - 5.0, Oper B - 5.0" to define the operations that happened in 24 hours. Basically time is separated by " - " from the operation code and each entry is separated by commas.

What I would like to have at the end is "Oper A - 11.0, Oper B - 8.0, Oper C - 5.0", meaning I would like to group the operation codes and sum their hours.

 

Anybody could suggest any approach to this? Thanks!

1 ACCEPTED SOLUTION

Hi @Anonymous

 

You can split those into their own rows using the same split function.  Just click the advanced option in the Split dialog and set something like this for your column.

 

 

split to rows.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
Phil_Seamark
Employee
Employee

Hi @Anonymous

 

First of all, try splitting the column into two columns.  I suggest doing this in the Query Editor.

 

 

PQ1.png

Then group them in the Query Editor.  This should give you the output you are after.

 

PQ2.png

 

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

 

Thank you for your reply Phil,

 

 

That part is easy, but the data I've got is a bit more complex. As I mention in my original post, there're several codes in the same text column, separated by commas, so splitting the columns will result in a variable number of extra columns. To get more context, see the screenshot of the column I'm taking about.

 

Timecode3Example.png

 

The number of codes could be different per row, and the times too.

 

Thank you! 

 

 

Hi @Anonymous

 

You can split those into their own rows using the same split function.  Just click the advanced option in the Split dialog and set something like this for your column.

 

 

split to rows.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Thank you @Phil_Seamark,

 

I think I had in my mind an easiest way to calculate "on-the-fly" (without creating extra columns) the values after the commas and group them by the operation codes. I'll try the splitting instead. Thank you again for your help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors