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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Grouping based on substring

Good Morning,

 

I am having a bit of trouble figurint this one out. 

I have a table called Escalations which contains one row per esclation in our product. 

 

One of the fields in that table is called "Category".  The values in  always start with a predefined value - for example here are some possible values for that field:

 

Admin- Permissions

Admin- Anuthoring

Coaching - Upload 

Coaching - Conversion

Coaching - Transcript

 

I want to create a table which will look like this:

 

Category               Number of Escalations in that category

 

Coaching              COUNTof all rows in the Escalations table that start with Coaching 

 

Admin                   COUNTof all rows in the Escalations table that start with Admin

 

 

I played around with Summarize but can't quite get it to work

 

Any help will be greatly appreciated.

 

Susan

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous  - One way to do this is:

1. Change the name of your column to Subcategory and add a new column called Category. The new column would contain everything prior to the dash and then remove the ending whitespace.

 

You can create and clean this new Category column  in Power Query with Extract and Trim:

Text Before Delimiter.PNGTrim.PNG

 

Alternatively, with DAX you can create a Calculated Column:

Category 2 = 
var dash_position = FIND(
    "-", 
    YourTable[SubCategory],
    1,
    100
)
var before_dash = MID(
    YourTable[SubCategory],
    1,
    dash_position-1
)
return TRIM(before_dash)

2. Your measure can then be a very simple one - count the number of rows in the table (or in some other related table):

Count YourTable = 
COUNTROWS(YourTable)

3. Add the new Category column and Measure to a visual.

Hope this helps,

Nathan

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Anonymous  - One way to do this is:

1. Change the name of your column to Subcategory and add a new column called Category. The new column would contain everything prior to the dash and then remove the ending whitespace.

 

You can create and clean this new Category column  in Power Query with Extract and Trim:

Text Before Delimiter.PNGTrim.PNG

 

Alternatively, with DAX you can create a Calculated Column:

Category 2 = 
var dash_position = FIND(
    "-", 
    YourTable[SubCategory],
    1,
    100
)
var before_dash = MID(
    YourTable[SubCategory],
    1,
    dash_position-1
)
return TRIM(before_dash)

2. Your measure can then be a very simple one - count the number of rows in the table (or in some other related table):

Count YourTable = 
COUNTROWS(YourTable)

3. Add the new Category column and Measure to a visual.

Hope this helps,

Nathan

Anonymous
Not applicable

Thank you very much. 

 

I don't know why I did not think of it before and was overcomplicating it like that.

 

What I ended up doign actually is based on your suggestionI created a table that had the values I needed ( Coaching, Admin etc since I know then before hand.

 

I added a visual for the number of total rows and the component field from the hard coded table.

 

With my solition I have to maintain the reference table vs your solution is better because it is dynamic so I will re-work mine to match yours.

 

Thanks again

 

Susan

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.