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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
dylanrollins
Regular Visitor

Sliceable Chart Featuring Multiple Table Columns

Hi,

I have a data table based on responses to an MS Form, with several yes/no questions being split out over separate columns. I.e.:

KeyCompanyDepartmentQuestion1Question2Question3
1company1department1NoYesNo
2company2department2Yes Yes
3company2department3NoNoYes
4company1department2   
5company2department1YesYesYes

 

I need to have the % of "Yes" answers for each question combined into a single bar chart (descending based on which question has the highest "Yes" %), but also have the chart be sliceable based on both Company and Department.

 

I've got the following chart:

dylanrollins_0-1673360497708.png

 

This was achieved using a calculated table, created with the following DAX:

 

calculated_table =
{
    ( "Question1", CALCULATE (
        COUNTROWS ( table1 ),
        FILTER ( 'table1', 'table1'[Question1] = "Yes" )
    )
        / CALCULATE (
            COUNTROWS ( table1 ),
            FILTER ( 'table1', 'table1'[Question1] <> "" )
        ) ),
    ( "Question2", CALCULATE (
        COUNTROWS ( table1 ),
        FILTER ( 'table1', 'table1'[Question2] = "Yes" )
    )
        / CALCULATE (
            COUNTROWS ( table1 ),
            FILTER ( 'table1', 'table1'[Question2] <> "" )
        ) ),
    ( "Question3", CALCULATE (
        COUNTROWS ( table1 ),
        FILTER ( 'table1', 'table1'[Question3] = "Yes" )
    )
        / CALCULATE (
            COUNTROWS ( table1 ),
            FILTER ( 'table1', 'table1'[Question3] <> "" )
        ) )
}

 

 

Which gave this result (with 'Column' being dropped in as the Y axis field):

dylanrollins_2-1673362185193.png

 

However, as this is a calculated table, it can't be affected by slicers.

 

The only other thing I can think of is to create separate measures for each column, then add them all into one chart. This will respond to selected slicer values, but just kind of looks terrible (no Y value labels, and moving the legend down the left barely works):

dylanrollins_1-1673361892672.png

 

Are there any workarounds for making calculated tables filterable by slicers, or any other completely different ideas?

1 REPLY 1
DataInsights
Super User
Super User

@dylanrollins,

 

A simpler solution is to unpivot the Question columns in Power Query. Here's the M code. I added the step ReplaceEmptyWithNull to replace empty strings with null (your model may not require this step, depending on your data).

 

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "i45WMlTSUUrOzy1IzKsEMVNSCxKLSnJT80pAPL98IBGZWgxhxupEKxkhlBuhKDeCq4QyQKqNcak2hhkOtwGk3ASXW4wgxoIQSJ0pLmMN4Y5AkLGxAA==",
          BinaryEncoding.Base64
        ),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [
        Key = _t,
        Company = _t,
        Department = _t,
        Question1 = _t,
        Question2 = _t,
        Question3 = _t
      ]
  ),
  ChangeType = Table.TransformColumnTypes(
    Source,
    {
      {"Key", Int64.Type},
      {"Company", type text},
      {"Department", type text},
      {"Question1", type text},
      {"Question2", type text},
      {"Question3", type text}
    }
  ),
  UnpivotColumns = Table.UnpivotOtherColumns(
    ChangeType,
    {"Key", "Company", "Department"},
    "Attribute",
    "Value"
  ),
  RenameColumn = Table.RenameColumns(UnpivotColumns, {{"Attribute", "Question"}}),
  ReplaceEmptyWithNull = Table.ReplaceValue(
    RenameColumn,
    "",
    null,
    Replacer.ReplaceValue,
    {"Value"}
  )
in
  ReplaceEmptyWithNull

 

DataInsights_0-1673447047809.png

 

Create measure:

 

Yes Answers = 
VAR vNumerator =
    CALCULATE ( COUNT ( Table1[Value] ), Table1[Value] = "Yes" )
VAR vDenominator =
    COUNT ( Table1[Value] )
VAR vResult =
    DIVIDE ( vNumerator, vDenominator )
RETURN
    vResult

 

DataInsights_1-1673447208369.png

---

 

DataInsights_2-1673447242353.png

 





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

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.