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
Rico56
New Member

Count value in columns

Hello,

 

I have something like this:

 

Clientcol1col2col2
c1OKOKOK
c2OKOKCRIT
c3WARNWARNOK
c4OKOKOK
c5OKCRITOK
c6WARNOKOK
c7OKOKOK
c8WARNOKWARN
c9OKOKOK

 

I try to make a calculated columns to have :

col1total
OK6
WARN3
CRIT0

 

col2total
OK7
WARN1
CRIT1

 

col3total
OK7
WARN1
CRIT1

 

I'm a beginner with Power BI.

Thanks in advance for your help.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Please check the solution at :https://www.dropbox.com/s/pzine68dy2tax7k/clientcount.pbix?dl=0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Rico56
New Member

Many thanks for all replies.

Now it works. I have many things to learn about Power BI.

smpa01
Super User
Super User

@Rico56  it can done tyhis way by using M

let
    Source = Web.BrowserContents("https://community.powerbi.com/t5/Desktop/Count-value-in-columns/m-p/926208#M443898"),
    #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > TR > :nth-child(1), DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > * > TR > :nth-child(1)"}, {"Column2", "DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > TR > :nth-child(2), DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > * > TR > :nth-child(2)"}, {"Column3", "DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > TR > :nth-child(3), DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > * > TR > :nth-child(3)"}, {"Column4", "DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > TR > :nth-child(4), DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > * > TR > :nth-child(4)"}}, [RowSelector="DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > TR, DIV[id='bodyDisplay'] > DIV.lia-message-body-content:nth-child(1) > TABLE:nth-child(5) > * > TR"]),
    #"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Client", type text}, {"col1", type text}, {"col2", type text}, {"col2_1", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"col2_1", "col3"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"Client"}),
    Custom1 = Table.DemoteHeaders(#"Removed Columns"),
    #"Changed Type2" = Table.TransformColumnTypes(Custom1,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type2"),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Transposed Table", {"Column1"}, "Attribute", "Value"),
    #"Removed Columns1" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns1", {"Column1", "Value"}, {{"Count", each Table.RowCount(_), type number}})
in
    #"Grouped Rows"

 

req.PNG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
amitchandak
Super User
Super User

Please check the solution at :https://www.dropbox.com/s/pzine68dy2tax7k/clientcount.pbix?dl=0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Unless you absolutely need it to be in a calculated column, you could drop col1/col2/col3 twice into the visual.

 

If you choose a table visual, drop the same column in the Value-well twice. The first one will show the distinct values in the column, and for the second one you choose the drop-down button on the column name in the Values-well, and choose Count.

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 Solution Authors
Top Kudoed Authors