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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
shparvez
New Member

Find percentage of text value in another column

Hello good people,

I am trying to find percentage of certain text value in another column. Can someone help please?

ContinentStatus
AsiaIn
AsiaIn
AsiaIn
AsiaIn
AsiaOut
AsiaOut
AfricaOut
AfricaOut
AfricaIn
AfricaIn

 

Result I am looking for percentage of Continent+Status in a new column.

 

ContinentStatusPercentage
AsiaIn40%
AsiaIn40%
AsiaIn40%
AsiaIn40%
AsiaOut20%
AsiaOut20%
AfricaOut20%
AfricaOut20%
AfricaIn20%
AfricaIn20%

 

Here, Asia In is 40%, where Asia Out is 20% , followed by Africa Out 20% so as Africa In 20%. 

Thank anyone for help in advance.

9 REPLIES 9
shparvez
New Member

Hi AlienSx,

Many thanks, yes it works, however, in my real table, there are many columns, not possible to do with 'group'.  Do you have any solution without 'group' ?  thanks

@shparvez expand as many columns as you want. Expand all of them!

expand = Table.ExpandTableColumn(pct, "rows", Table.ColumnNames(source_table))

While 'grouping' , I have to mentions all other columns names, not?  Thats very difficult, as I have too many columns. 

 g = Table.Group(
        source_table, 
        {"Continent", "Status"}, 
        {{"rows", each _}, {"Percentage", each Table.RowCount(_), Int64.Type}}

@shparvez no, don't do that. Leave them alone. That's the idea behind Table.Group. Just change expand step. 

Hi,

Suppose the table is as below

Column1, Column2, Column3, Column4, Column5, Column6..... ColumnN

 

I want to find percetage for values of Column 5 only.  Can you rewrite the code please without mentioning any other columns  ?   Thank you in advance.

     g = Table.Group(
        source_table, 
        "Column5", 
        {{"rows", each _}, {"Percentage", each Table.RowCount(_), Int64.Type}}
    )[[rows], [Percentage]],
    ttl = List.Sum(g[Percentage]),
    pct = Table.TransformColumns(g, {"Percentage", each _ / ttl}),
    expand = Table.ExpandTableColumn(pct, "rows", Table.ColumnNames(source_table))

Hi ,

An error message appears - "Expression.Error: The “Percentage” field already exists in the record."

hi

1.jpg2.jpg3.jpg

 

 

AlienSx
Super User
Super User

hello, @shparvez 

    g = Table.Group(
        source_table, 
        {"Continent", "Status"}, 
        {{"rows", each _}, {"Percentage", each Table.RowCount(_), Int64.Type}}
    )[[rows], [Percentage]],
    ttl = List.Sum(g[Percentage]),
    pct = Table.TransformColumns(g, {"Percentage", each _/ttl}),
    expand = Table.ExpandTableColumn(pct, "rows", {"Continent", "Status"}, {"Continent", "Status"})

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors