AlexSC
AlexSC

Reputation: 1933

How to build a bar chart in Power BI from a questionnaire

My scenario is like that:

  1. I have a table containing answers from a survey with two questions;
  2. Each question has only three possible options: "yes", "no", "n/a".

What I need is a bar chart that shows how many questions with "yes" I have for each question. The final chart should have two colunms, one labeled "Q01" and other "Q02" (those are the names of the columns), each column counting the "yes" for the corresponding question.

That should be simple with filters and a clustered bar chart. Set the two columns (Q01 and Q02) to Y axis and one filter to each column to select only "yes". However, when I set the two columns together Power BI displais both columns with the same size, with what looks like the intersection of the both columns.

How to fix it?

Sample data

This is a simple example:

enter image description here

Generated from Sample = {(1, "yes", "yes"),(2, "no", "yes"),(3, "no", "yes"),(4, "yes", "no"),(5, "yes", "yes")}

The result is

enter image description here

Upvotes: 2

Views: 1028

Answers (1)

davidebacci
davidebacci

Reputation: 30219

Import your data into power query.

enter image description here

Select id columns and then unpivot other columns from the ribbon.

enter image description here

Close and apply.

Add a measure:

Measure = CALCULATE(COUNTROWS('Table'), 'Table'[Value] = "yes")

Add a stacked bar and add the following to the field well.

enter image description here

Upvotes: 1

Related Questions