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
Anonymous
Not applicable

How to calculate average in a column with string value on it

Hey guys, 

 

I'm quite new on PowerBi usage and I need your help.

 

In the column I have a mix of number of values (represented as "OK"), in my dashboard I need to create a box with a formula on it where I filter out the rows with value "OK" then calculate the average of the remaning.

 

Capture.PNG

 

Suggestions? 

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @Anonymous ,

 

How about this:

tomfox_0-1650391966521.png

 

 

Here the code:

MeasureText&Numbers = 
CALCULATE ( 
    AVERAGEX ( Table20, CONVERT ( Table20[Durata step 2], INTEGER) ),
    Table20[Durata step 2] <> "OK"
)

 

While the measure above should work, I'd recommend to clean your data in that column before loading it into PBI. If the OKs and the numbers are important, I'd suggest to create a new column with the OKs and substitute the OKs in Durata Step 2 with blanks() in Power Query. But that shall just be a humble suggestion 🙂

 

Hope the formular gets you closer to a solution anyway 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

1 REPLY 1
tackytechtom
Super User
Super User

Hi @Anonymous ,

 

How about this:

tomfox_0-1650391966521.png

 

 

Here the code:

MeasureText&Numbers = 
CALCULATE ( 
    AVERAGEX ( Table20, CONVERT ( Table20[Durata step 2], INTEGER) ),
    Table20[Durata step 2] <> "OK"
)

 

While the measure above should work, I'd recommend to clean your data in that column before loading it into PBI. If the OKs and the numbers are important, I'd suggest to create a new column with the OKs and substitute the OKs in Durata Step 2 with blanks() in Power Query. But that shall just be a humble suggestion 🙂

 

Hope the formular gets you closer to a solution anyway 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.