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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors