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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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