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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dofrancis3
Helper III
Helper III

DAX Pourcentage Calculation for text format

Dear Colleagues,

Please i need your help !

According to the table below, at "% Status" column i would like to calculate percentage of status  (Fail and Pass)

The formula is: Fail or Pass divise by total Fail and pass

Here the my DAX mesure for calculed the total nbr of satatus: 

Tot number of Status =

VAR __numberOfInterwd =
CALCULATE (
    COUNTROWS ( repository ),
    ( repository[STATUS] = "Pass"
        || repository[STATUS] = "Fail" )
)
RETURN
IF(ISBLANK(__numberOfInterwd), "No Data",__numberOfInterwd)

 

CountryStaus% Status
CDFail 
MEPass 
CD  
CDPass 
MEFail 
CDPass 
MEPass 
CDFail 
CDPass 
CDFail 
CDPass 
ME  
CDPass 
CDPass 
MEFail 
CDPass 
CDFail 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @dofrancis3 

Thank you very much for your reply. First, you need to change the expression of the calculated column to:

Percentage = 
VAR _status_fail = CALCULATE(COUNTROWS('repository'),FILTER('repository','repository'[Country]=EARLIER(repository[Country])&&'repository'[Staus]="Fail"||'repository'[Staus]="Pass"))
VAR _total_status = CALCULATE(COUNTROWS('repository'),FILTER(ALL(repository),'repository'[Staus]="Fail"||'repository'[Staus]="Pass")) 
RETURN IF(NOT ISBLANK('repository'[Staus]),DIVIDE(_status_fail,_total_status))

In the top navigation bar, format this column without percentages:

vjianpengmsft_0-1716262013724.png

vjianpengmsft_1-1716262062520.png

vjianpengmsft_2-1716262159454.png

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

Hi, @dofrancis3 

Based on your description, I've created the following calculation table formula:

Percentage = 
VAR _status_fail = CALCULATE(COUNTROWS('repository'),FILTER('repository','repository'[Country]=EARLIER(repository[Country])&&'repository'[Staus]="Fail"||'repository'[Staus]="Pass"))
VAR _total_status = CALCULATE(COUNTROWS('repository'),FILTER(ALL(repository),'repository'[Staus]="Fail"||'repository'[Staus]="Pass")) 
RETURN IF(NOT ISBLANK('repository'[Staus]),FORMAT(DIVIDE(_status_fail,_total_status),"0.0%"))

This variable _total_status used to count the total number of rows in the table that passes and fails. _status_fail is used to find the number of pass and fail rows in the current country. Use IF to determine that the current status is not empty, and then find the percentage of pass and fail. The result is formatted as a percentage in text format via the format function.

Here are the results:

vjianpengmsft_1-1716169779279.png

I'm not sure I fully understand what you mean. If you don't understand something, can you describe the output you expect based on the sample data you provide? I've provided the PBIX file used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

 

Dear @Anonymous thank you for this but please could you let me know how can i change the percentage in "Whole or Percentage format" because the percentage is in text format and i can't make any chart. 

dofrancis3_0-1716197943571.png

Please suport 

Anonymous
Not applicable

Hi, @dofrancis3 

Thank you very much for your reply. First, you need to change the expression of the calculated column to:

Percentage = 
VAR _status_fail = CALCULATE(COUNTROWS('repository'),FILTER('repository','repository'[Country]=EARLIER(repository[Country])&&'repository'[Staus]="Fail"||'repository'[Staus]="Pass"))
VAR _total_status = CALCULATE(COUNTROWS('repository'),FILTER(ALL(repository),'repository'[Staus]="Fail"||'repository'[Staus]="Pass")) 
RETURN IF(NOT ISBLANK('repository'[Staus]),DIVIDE(_status_fail,_total_status))

In the top navigation bar, format this column without percentages:

vjianpengmsft_0-1716262013724.png

vjianpengmsft_1-1716262062520.png

vjianpengmsft_2-1716262159454.png

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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