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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
swilder
Regular Visitor

Smartsheet+PowerBi Count Rows that Contain Formula

Hello!

 

I am trying to get a formula to count the number of times a word or phrase appears in a column. The data is from a Smartsheet, pulled into PowerBi. The Smartsheet column type is a multi-select drop-down, but in PowerBi the column type is simply Text.

 

Below is an example with generic info that represents the data and issues I am having. 

DayFruit
MondayApple
TuesdayBanana, Apple
WednesdayPear

 

I would like a formula that would return 2 for Apple, as it is listed twice. 

 

The current formulas (below) return 1, even though the word apple appears twice in the column.

 

#Apples =
CALCULATE(
COUNTROWS('Table1'),
'Table1'[Fruit] IN ({"Apple"})
)
 
Count of Apples =
CALCULATE(
COUNTA('Table1']),
'Table1'[Fruit] IN { "Apple" }
)
 
Any other formula ideas would be greatly, greatly appreciated!
1 ACCEPTED SOLUTION
bolfri
Solution Sage
Solution Sage

Direct answer:

# Apples = 
CALCULATE(
    COUNTROWS(SampleData),
    CONTAINSSTRING(SampleData[Fruit],"Apple")
)

bolfri_0-1690922613231.png

Better solution:

Use Power Query M editor to split Fruit's into rows.

bolfri_1-1690922741087.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8s3PS0msVNJRciwoyElVitWJVgopTS2GiDkl5gGhjgJCLjw1JQ8mG5CaWKQUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Day = _t, Fruit = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,", ",",",Replacer.ReplaceText,{"Fruit"}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Replaced Value", {{"Fruit", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Fruit"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Fruit", type text}})
in
    #"Changed Type1"

BetterData:

bolfri_2-1690922795948.pngbolfri_3-1690922919676.png

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
bolfri
Solution Sage
Solution Sage

Direct answer:

# Apples = 
CALCULATE(
    COUNTROWS(SampleData),
    CONTAINSSTRING(SampleData[Fruit],"Apple")
)

bolfri_0-1690922613231.png

Better solution:

Use Power Query M editor to split Fruit's into rows.

bolfri_1-1690922741087.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8s3PS0msVNJRciwoyElVitWJVgopTS2GiDkl5gGhjgJCLjw1JQ8mG5CaWKQUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Day = _t, Fruit = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,", ",",",Replacer.ReplaceText,{"Fruit"}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Replaced Value", {{"Fruit", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Fruit"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Fruit", type text}})
in
    #"Changed Type1"

BetterData:

bolfri_2-1690922795948.pngbolfri_3-1690922919676.png

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you so very much. The information above was tremendously helpful in solving my issue. 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.