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

percentage of column with text values

Hi there

 

Probably an easy one for the seasoned PowerBi developer. I'm a newbie.

we looking to find percentage for column status where value is "OnTime". I already have a table for date dimension which we'll use to visualize data by month

 

DateStatus
01-MarOnTime
04-MarLate
04-AprUndetermined
07-AprLate
05-JunOnTime
08-JulOnTime
01-AugLate
03-AugUndetermined
2 ACCEPTED SOLUTIONS
PC2790
Community Champion
Community Champion

Hello,

 

You can use this DAX measure to achieve it:

%OnTimeStatus = DIVIDE(CALCULATE(COUNTA(StatusTable[Status]),FILTER(StatusTable,StatusTable[Status] = "OnTime")),CALCULATE(COUNTA(StatusTable[Status]),ALLEXCEPT(StatusTable,StatusTable[Status])))

Also ensure to click on the measure & change the format to percentage.

This will give you the percentage of On Time on the basis of total rows in your table.

 

I hope I interpreted your requirement correctly.

Please respond back if you are looking for something else 

View solution in original post

PC2790
Community Champion
Community Champion

Sure you can. Both will work for you.

Infact COUNTROWS will give more efficient result for you.

View solution in original post

9 REPLIES 9
PC2790
Community Champion
Community Champion

Hello,

 

You can use this DAX measure to achieve it:

%OnTimeStatus = DIVIDE(CALCULATE(COUNTA(StatusTable[Status]),FILTER(StatusTable,StatusTable[Status] = "OnTime")),CALCULATE(COUNTA(StatusTable[Status]),ALLEXCEPT(StatusTable,StatusTable[Status])))

Also ensure to click on the measure & change the format to percentage.

This will give you the percentage of On Time on the basis of total rows in your table.

 

I hope I interpreted your requirement correctly.

Please respond back if you are looking for something else 

Anonymous
Not applicable

Could i have used 

%OnTimeStatus = DIVIDE(CALCULATE(COUNTROWS(StatusTable),StatusTable[Status] = "OnTime"),CALCULATE(COUNTROWS(StatusTable)))

THis seems to give me a different result which looks more accurate tho
PC2790
Community Champion
Community Champion

Sure you can. Both will work for you.

Infact COUNTROWS will give more efficient result for you.

This has been super useful to a problem I am trying to tackle as well however I need to exclude the "blanks" in this column prior to the calculation. How would I edit the measure to achieve this?

PC2790
Community Champion
Community Champion

You can use COUNTROWS DAX function with an expression. Something like below:

 

%OnTimeStatus = DIVIDE(CALCULATE(COUNTROWS(FILTER(StatusTable,StatusColumn <> null)),StatusTable[Status] = "OnTime"),CALCULATE(COUNTROWS(StatusTable)))

 Used:

(COUNTROWS(FILTER(StatusTable,StatusColumn <> null))

I have given that a go however receive the error message "operator or expression 'NULL' is not supported in this context. I have included the measure I have used below.
 
"Psych Data" is my table name, and "Appointment Required" is my column in which I want to work out how many are "Yes".
 
Measure = DIVIDE(CALCULATE(COUNTROWS(FILTER('Psych data','Psych data'[Appointment required]<>null)),'Psych data'[Appointment required]="Yes"),CALCULATE(COUNTROWS('Psych data')))
PC2790
Community Champion
Community Champion

Try:

 

Measure = DIVIDE(CALCULATE(COUNTROWS(FILTER('Psych data','Psych data'[Appointment required]<> BLANK())),'Psych data'[Appointment required]="Yes"),CALCULATE(COUNTROWS('Psych data')))

That's resulted in the same figure unfortunately.

 

Thankfully though I have managed to sort it; with some help from a work colleague. I really appreciate you taking the time though.

Anonymous
Not applicable

Thanx PC2790

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.

Top Solution Authors