Forum Discussion
kangkopi15
Helper I
2 years agoPercentage 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.. ...
- 2 years ago
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
collinsg
Solution Sage
2 years agoGood 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
- kangkopi152 years ago
Helper I
I got syntax error
- collinsg2 years ago
Solution 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
- kangkopi152 years ago
Helper I
hi collin, my bad the syntax is correct, i didn't change the column name, however how can I change that to percentage?