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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
RichOB
Post Patron
Post Patron

Turning numbers into percent's with calculations

Hi, I need help with some calculations for a survey.

 

In the example below the survey consists of 3 questions that are always in number form, “I Am Happy, I am Sad, I Am Neither”. The most 1 person can score per question is always 5 which means the total possible survey score is always 15. I need help with calculations to change them into percentages. The Total by City doesn't have a fixed number to calculate against (like 15 above) as it always changes due to the number of people within the city varying. 

 

1 – Total by City. How can I turn the numbers into % based on the amount of people who took the survey:

  • For example, 5 people from Newcastle took the survey so the total possible score is 75. They scored 66….66 / 75 x 100 = Newcastle average total score is 86.7%

 

2 – Total By Question – How can I get the % based on the score per question:

  • For example, Newcastle scored 21 out of 25 for “ I Am Happy “ = all people in Newcastle who picked I Am Happy is 84%

 

3 – Total By Person - For example, if Person 1 scored 13 out of 15, their score is 86.6%

 

I hope this makes sense, happy to give more information and thanks in advance.

 

PersonCompletion timeI Am HappyI Am Sad I Am NeitherArea CityPet 
103/01/2024445North NewcastleDog
211/01/2024555North NewcastleDog
325/01/2024334North NewcastleDog
429/01/2024445North NewcastleCat
501/02/2024555North NewcastleCat

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @RichOB ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create measures. 

Total By city = 
var _a=CALCULATE(DISTINCTCOUNT('Table'[Person]),FILTER(ALLSELECTED('Table'),'Table'[City]=MAX('Table'[City])))
var _b=_a*15
var _c=CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),'Table'[City]=MAX('Table'[City])))
RETURN DIVIDE(_c,_b,0)
Total By Question = 
var _a=CALCULATE(DISTINCTCOUNT('Table'[Person]),FILTER(ALLSELECTED('Table'),'Table'[City]=MAX('Table'[City])))
var _b=_a*5
var _c=CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),'Table'[City]=MAX('Table'[City]) && 'Table'[Attribute]=MAX('Table'[Attribute])))
RETURN DIVIDE(_c,_b,0)
Total By Person = 
var _a=CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),'Table'[Person]=MAX('Table'[Person])))
var _b=15
RETURN DIVIDE(_a,_b,0)

(3) Then the result is as follows.

vtangjiemsft_0-1715323162539.png

Best Regards,

Neeko Tang

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

1 REPLY 1
Anonymous
Not applicable

Hi @RichOB ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create measures. 

Total By city = 
var _a=CALCULATE(DISTINCTCOUNT('Table'[Person]),FILTER(ALLSELECTED('Table'),'Table'[City]=MAX('Table'[City])))
var _b=_a*15
var _c=CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),'Table'[City]=MAX('Table'[City])))
RETURN DIVIDE(_c,_b,0)
Total By Question = 
var _a=CALCULATE(DISTINCTCOUNT('Table'[Person]),FILTER(ALLSELECTED('Table'),'Table'[City]=MAX('Table'[City])))
var _b=_a*5
var _c=CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),'Table'[City]=MAX('Table'[City]) && 'Table'[Attribute]=MAX('Table'[Attribute])))
RETURN DIVIDE(_c,_b,0)
Total By Person = 
var _a=CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),'Table'[Person]=MAX('Table'[Person])))
var _b=15
RETURN DIVIDE(_a,_b,0)

(3) Then the result is as follows.

vtangjiemsft_0-1715323162539.png

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.