Forum Discussion
Percentage of value
Dear experts,
I am quite new to DAX, I need a little advice. I have this table, and I need to make a percentage of the score.
The output would be
Score 1 = 14.28%
Score 2 = 42.86%
and so on..
| Name | Score |
| Anna | 1 |
| Alan | 2 |
| Tobi | 3 |
| Sam | 2 |
| Tonny | 2 |
| Toffon | 4 |
| Bram | 5 |
Good day kangkopi15,
It looks like you want to find the percentage of scores which are 1, 2...5. If this is the case you can create a matrix visual, put "Score" in rows and use this measure for the values.
Percentage frequency of score =
VAR thisScore = SELECTEDVALUE(tbl[Score])
VAR countOfAllScores = CALCULATE(COUNTROWS('tbl'),REMOVEFILTERS('tbl'))
VAR countOfScore = CALCULATE(COUNTROWS('tbl'),REMOVEFILTERS('tbl'),'tbl'[Score]=thisScore)
RETURN DIVIDE(countOfScore, countOfAllScores)Hope this helps
7 Replies
- collinsgSolution Sage
Good day kangkopi15,
It looks like you want to find the percentage of scores which are 1, 2...5. If this is the case you can create a matrix visual, put "Score" in rows and use this measure for the values.
Percentage frequency of score =
VAR thisScore = SELECTEDVALUE(tbl[Score])
VAR countOfAllScores = CALCULATE(COUNTROWS('tbl'),REMOVEFILTERS('tbl'))
VAR countOfScore = CALCULATE(COUNTROWS('tbl'),REMOVEFILTERS('tbl'),'tbl'[Score]=thisScore)
RETURN DIVIDE(countOfScore, countOfAllScores)Hope this helps
- kangkopi15Helper I
I got syntax error
- collinsgSolution Sage
kangkopi15
- Did you replace "tbl" with the name of your table?
- Is your "Score" column a number type?
The syntax is correct and gives the answers to the problem.
Hope this helps
- zenisekdSuper User
Could you explain better how do you want to calculate it? Your description makes very little sense.
is 1 = 14,28%
so 3 = 3*14,28%?
Or do you want to calculate a % of a grand total?- kangkopi15Helper I
I am looking for the score percentage..
score 1, there is only one person put score 1, so from the total people who participated (7) the ratio or percentage of score 1 is 1/7 which would be around 14,28%