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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Count Based on a Filter

I have a single table with a column containing percentage values and I want to count the number of values greater than 50%

How do I achieve that?

2019-10-05 00_29_59-All Impact Data - Power BI Desktop.png

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi dmutua,

We can't compare numberic value to text value, so you could try to convert data type to Decimal number , then use above count measure, or you could create a colum like below, extract whole number and convert this as Whole number, then use count measure.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlLSUTI0MFBVitWJVkoGcsCMFCADSczIGMiOBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [name = _t, p = _t]),
    #"Inserted Text Before Delimiter" = Table.AddColumn(Source, "Text Before Delimiter", each Text.BeforeDelimiter([p], "%"), type text),
    #"Changed Type" = Table.TransformColumnTypes(#"Inserted Text Before Delimiter",{{"Text Before Delimiter", Int64.Type}})
in
    #"Changed Type"

Best Regards,
Zoe Zhi

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

3 REPLIES 3
amitchandak
Super User
Super User

Please try

Calculate(countrows(table1),value>50)
OR
Calculate(countrows(table1),value>.50)

Appreciate your Kudos. In case, this is the solution you are looking for, mark it at Solution.
Thanks.

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi,

 

Thank you,the column I am trying to count is formatted as text because it has whole number and som text values.

 

What are my options in performing a countrows function on a text formatted column?

 

Thanks

dax
Community Support
Community Support

Hi dmutua,

We can't compare numberic value to text value, so you could try to convert data type to Decimal number , then use above count measure, or you could create a colum like below, extract whole number and convert this as Whole number, then use count measure.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlLSUTI0MFBVitWJVkoGcsCMFCADSczIGMiOBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [name = _t, p = _t]),
    #"Inserted Text Before Delimiter" = Table.AddColumn(Source, "Text Before Delimiter", each Text.BeforeDelimiter([p], "%"), type text),
    #"Changed Type" = Table.TransformColumnTypes(#"Inserted Text Before Delimiter",{{"Text Before Delimiter", Int64.Type}})
in
    #"Changed Type"

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.