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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
AgustinBrocardo
Frequent Visitor

bar and column chart - add a field per column

Hi!

I´m have a database for a survey where i have one question per colmn. It looks like this:


Customers,Question1,Quesiton2,Question3,Question4,Question5

Customer1,3,3,3,3,3

Customer2,4,4,3,4,3

Customer3,5,3,4,2,4 

 

The answers are numbers from 1 to 5 and i want to make a bar/column chart where each column of the char represents the average answer for each question.

 

In power bi, without editing the imported data, i have one field for each column: 

AgustinBrocardo_0-1635947211271.png

 

Is there a way to add each question as a column in the bar chart? The solution i found is unpivoting the question columns but it´s a problem because i need to use the individual questions for other visuals and analysis.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@AgustinBrocardo , Create a new table that has values from Question1 to Question5 in rows in question columns

 

then try a measure

Switch(max(Question[Question]) ,

"Question 1", Sum(Table[Question 1]) ,

"Question 2", Sum(Table[Question 2]) ,

"Question 3", Sum(Table[Question 3]) ,

"Question 4", Sum(Table[Question 4]) ,

"Question 5", Sum(Table[Question 5])

)

 

Then use question from the question table in visual and try

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@AgustinBrocardo , Create a new table that has values from Question1 to Question5 in rows in question columns

 

then try a measure

Switch(max(Question[Question]) ,

"Question 1", Sum(Table[Question 1]) ,

"Question 2", Sum(Table[Question 2]) ,

"Question 3", Sum(Table[Question 3]) ,

"Question 4", Sum(Table[Question 4]) ,

"Question 5", Sum(Table[Question 5])

)

 

Then use question from the question table in visual and try

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak I couldn´t make it work. There´s also a fact i didn´t mention and it may be important, the database will be updated every two months, it won´t be a one time report

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.