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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Percentage of Column

New to DAX here and I am having trouble with a formula. IF I have one column like below how could I calculate the the count of Y by the total count of All.  So I would like to calculate that the selected value by the total value. ( 1 Yes)/ (4) = .25

 

Column Name: Y/N
Y
N
N
N
1 ACCEPTED SOLUTION
TD21
Helper II
Helper II

A few ways to do this, one of which is creating 3 separate measures:

 

M_TOTAL = COUNT(Table[Column])

M_YES = CALCULATE ( COUNT(Table[Column]) , Table[Column] = "Y" )

M_YES_PERCENT = DIVIDE ( [M_YES] , [M_TOTAL] )

 

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can create a measure as below:

 

Measure = 
var a =CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Column Name: Y/N]="Y"))
var b=COUNTROWS(ALL('Table'))
Return
IF(MAX('Table'[Column Name: Y/N])="Y",DIVIDE(a,b),BLANK())

 

You can just return :  DIVIDE(a,b) , but if you just wanna show the rows which contain "Y",use the measure above,and you will see:

Annotation 2020-04-22 151257.png

Or you can create a calculated column as below:

 

Column = 
var a =CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Column Name: Y/N]="Y"))
Return
IF('Table'[Column Name: Y/N]="Y",DIVIDE(a,COUNTROWS('Table')),BLANK())

 

And you will see:

Annotation 2020-04-22 151422.png

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
amitchandak
Super User
Super User

@Anonymous 


% = divide(count(Table[Column], Table[Column]="Y"),count(Table[Column]))

OR
% = divide(count(Table[Column], Table[Column]="Y"),calculate(count(Table[Column]),allselected(Table)))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
TD21
Helper II
Helper II

A few ways to do this, one of which is creating 3 separate measures:

 

M_TOTAL = COUNT(Table[Column])

M_YES = CALCULATE ( COUNT(Table[Column]) , Table[Column] = "Y" )

M_YES_PERCENT = DIVIDE ( [M_YES] , [M_TOTAL] )

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.