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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
mfriedrich228
Regular Visitor

Calculate amount of answers given to questions per year for all question columns in the table

Hi everyone,

I'm still fairly new to Power BI and learning a lot still, right now I have the following table structure of a survey in Power BI:

Question 1Question 2Question 3TeamYearVotecount
YesMaybeYesTeam 120191
NoNoNoTeam 120201
YesNoMaybeTeam 120211
MaybeNoNoTeam 120201
MaybeYesYesTeam 120191
NoYesMaybeTeam 120211


So what I would like to do is to count the votecount for every answer per year per question, so I can display the calculated values in a bar chart later. For each year and answer there would be a bar. What I did try until now, I looked up different DAX formulas but none seemed really helpful for what I do here to my knowledge. What I got to work is the desired result for a single question, the formula I used is this one:

Calculated Votecount Question 1 = 
var _votes = sum('Question 1'[Votecount])
var _allVotes =
calculate(
    sum('Question 1'[Votecount]),
    ALLEXCEPT('Question 1','Question 1'[Year])
)

return divide( _votes, _allVotes)

So my question to you is, is what I'm trying to do there possible at all or is the approach really to do that for every question with a measure again?

Kind regards

Maximilian

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

If you have acces to powerquery I would change the table a bit:

Select these columns and unpivot the values:

ValtteriN_0-1643298801145.png

By doing this your table will look like this:

ValtteriN_1-1643298857015.png


Now that the data is in this format we don't even need dax:

ValtteriN_2-1643299023835.png
If you want to do this with DAX ping me with @

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ValtteriN
Super User
Super User

Hi,

If you have acces to powerquery I would change the table a bit:

Select these columns and unpivot the values:

ValtteriN_0-1643298801145.png

By doing this your table will look like this:

ValtteriN_1-1643298857015.png


Now that the data is in this format we don't even need dax:

ValtteriN_2-1643299023835.png
If you want to do this with DAX ping me with @

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




It did solve my problem and I don't need to do it with DAX here, all I needed at this point was a solution to the problem, thanks a lot for your time and efforts!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.