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

How to count distinct values in a column?

Hello,

 

How can I count only the "1" in al column.

The column has 3 different values:  1, [Empty] and -1.

I need it to make a measure: percentage of the "1" of the total  (1 and -1).  

 

Thanks,

Mark

2 ACCEPTED SOLUTIONS
Chihiro
Solution Sage
Solution Sage

There are several ways.

 

I'd probably use...

=COUNTROWS(FILTER(Table, [Column]=1))

View solution in original post

affan
Solution Sage
Solution Sage

Hi @Anonymous,

 

You can use the following measure for count

 

Count1 = CALCULATE(COUNT(Table1[Column1]),FILTER(Table1,Table1[Column1]=1))

For calculating the percent you can use the following measure 

 

 

Percent = var rowsc=COUNTROWS(Table1)
return 
CALCULATE([Count1]/rowsc)*100

count1.png

You can view the pbix file here

 

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

 

Regards,

Affan

View solution in original post

3 REPLIES 3
AkhilAshok
Solution Sage
Solution Sage

Do you mean this:

PercentageOfOne =
VAR CountOfOne =
    CALCULATE ( COUNTROWS ( Table ), Table[Column] = 1 )
VAR CountOfRest =
    CALCULATE ( COUNTROWS ( Table ), NOT ( ISBLANK ( Table[Column] ) ) )
RETURN
    DIVIDE ( CountOfOne, CountOfRest )

 

affan
Solution Sage
Solution Sage

Hi @Anonymous,

 

You can use the following measure for count

 

Count1 = CALCULATE(COUNT(Table1[Column1]),FILTER(Table1,Table1[Column1]=1))

For calculating the percent you can use the following measure 

 

 

Percent = var rowsc=COUNTROWS(Table1)
return 
CALCULATE([Count1]/rowsc)*100

count1.png

You can view the pbix file here

 

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

 

Regards,

Affan

Chihiro
Solution Sage
Solution Sage

There are several ways.

 

I'd probably use...

=COUNTROWS(FILTER(Table, [Column]=1))

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.