Hi everyone,
I have the following table structure:
Team | Year | Votecount | Question | Answer |
Development | 2021 | 1 | Do you like your job? | Yes |
Development | 2021 | 1 | Do you like your job? | Yes |
Development | 2021 | 1 | Do you like your job? | No |
Development | 2021 | 1 | Are you happy with your salary? | Yes |
Development | 2020 | 1 | Are you happy with your salary? | No |
Development | 2019 | 1 | Are you happy with your salary? | No |
Now what I would like to do in a bar chart is to display the percentage of every answer per year of the total per year. So for the first question it should be ~66,66% for "Yes" in the year 2021 and ~33,33% for "No". I can't use the build in Power BI function to calculate my percentage values since that is looking at all answers of all 3 years then calculates the percentages of that. I have a measure that surprisngly when I don't sort the table at all, but breaks as soon as I need to sort it:
Vote % =
Divide(
count( [Answer] ),
Calculate(
count( [Answer] ),
all( 'Survey'[Team] ),
all( 'Survey'[Answer] )
)
)
Maybe someone of you sees or knows what I might do wrong or if there is a better alternative for doing that, thanks for your time!
Kind regards
Maximilian
Solved! Go to Solution.
Hi,
Test this:
Proud to be a Super User!
Instead of removing the filter context on specific columns, another option is specify which columns to keep in the filter context using ALLEXCEPT. This removes the filter context on all columns except the ones you specify.
For example,
Vote % =
DIVIDE (
COUNT ( 'Survey'[Answer] ),
CALCULATE (
COUNT ( 'Survey'[Answer] ),
ALLEXCEPT ( 'Survey', 'Survey'[Year], 'Survey'[Question] )
)
)
As ValterriN said I don;t see how sorting can affect a measure. Hopefully his suggested DAX works for you.
It's possible to visualise this without any DAX. You can use the 100% Stacked Column Chart and a slicer on Year to get your answer.
Hi,
Test this:
Proud to be a Super User!