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

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

Reply
mysho999
Frequent Visitor

Count if cell contains text (Across more columns)

Hello,
I would need to calculate for each row in the table how many times the word "ÁNO", "NIE", ...
But the joke is that I need to count it not for the entire row but only for the selected columns in that row.

 

Thank you very much

 

Table:

Snímka.PNG

2 ACCEPTED SOLUTIONS
v-diye-msft
Community Support
Community Support

Hi @mysho999 ,

 

I created a sample like this, and we’d like to calculate the counts of “ANO” & ”NIE” in selected columns for each row.

Attached pbix here for your reference: https://wicren-my.sharepoint.com/:u:/g/personal/dinaye_wicren_onmicrosoft_com/Ec6dsXHB20VMvdBdwazyAA...

1.png

We should have the slicer for selecting different columns, thus we do below steps in query editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvTzV9KBkn6erlAyVicaRQyhCiSDLoYugywPMw1TBqbHEch2AmJnIHZRio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t, D = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"B", type text}, {"C", type text}, {"D", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
    #"Transposed Table" = Table.Transpose(#"Added Index"),
    #"Reversed Rows" = Table.ReverseRows(#"Transposed Table"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Reversed Rows", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"1", type text}, {"2", type text}, {"3", type text}, {"4", type text}, {"5", type text}, {"6", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"6"}, "Attribute", "Value")
in
#"Unpivoted Other Columns"

Please note that A,B,C,D are the columns name, and 1,2,3,4,5 are the Rows index

2.png

Applied the change, add the slicer of columns and rows, and use the measures:

Times of ANO = CALCULATE(COUNTROWS(Table2),FILTER(Table2,[Value]="ANO"))
Times of NIE = CALCULATE(COUNTROWS(Table2),FILTER(Table2,[Value]="NIE"))

3.png

Best regards,

Dina Ye

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

 

Hi @mysho999 ,

 

If my above post helps, could you please consider Accept it as the solution to help the other members find it more quickly. thanks!

 

Best regards,

Dina Ye

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

2 REPLIES 2
v-diye-msft
Community Support
Community Support

Hi @mysho999 ,

 

I created a sample like this, and we’d like to calculate the counts of “ANO” & ”NIE” in selected columns for each row.

Attached pbix here for your reference: https://wicren-my.sharepoint.com/:u:/g/personal/dinaye_wicren_onmicrosoft_com/Ec6dsXHB20VMvdBdwazyAA...

1.png

We should have the slicer for selecting different columns, thus we do below steps in query editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvTzV9KBkn6erlAyVicaRQyhCiSDLoYugywPMw1TBqbHEch2AmJnIHZRio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t, D = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"B", type text}, {"C", type text}, {"D", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
    #"Transposed Table" = Table.Transpose(#"Added Index"),
    #"Reversed Rows" = Table.ReverseRows(#"Transposed Table"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Reversed Rows", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"1", type text}, {"2", type text}, {"3", type text}, {"4", type text}, {"5", type text}, {"6", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"6"}, "Attribute", "Value")
in
#"Unpivoted Other Columns"

Please note that A,B,C,D are the columns name, and 1,2,3,4,5 are the Rows index

2.png

Applied the change, add the slicer of columns and rows, and use the measures:

Times of ANO = CALCULATE(COUNTROWS(Table2),FILTER(Table2,[Value]="ANO"))
Times of NIE = CALCULATE(COUNTROWS(Table2),FILTER(Table2,[Value]="NIE"))

3.png

Best regards,

Dina Ye

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

 

Hi @mysho999 ,

 

If my above post helps, could you please consider Accept it as the solution to help the other members find it more quickly. thanks!

 

Best regards,

Dina Ye

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

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.