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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Datagrl
Regular Visitor

Calculate Percentage of Positive Responses

Hi PBI People!

 

I am working on reports for a satisfaction survey, and am having difficulty figuring out how to add a conditional percentage column to my matrix visualization.

 

My matrix lists each question on the left, followed by columns showing the total counts of responses for each of the likert ratings.  I need to add a column at the end showing what percentage of responses were "Agree" or "Strongly Agree" (i.e., a question receives 10 responses total, and there are 3 "Agrees" and 4 "Strongly Agrees" so I want a column at the end that shows 70%).

 

Can anyone help me figure out how to do this?  Thanks! 🙂

Save

1 ACCEPTED SOLUTION

Hi @Datagrl,

 

From above snapshot of your matrix, suppose that your table view looks like:

1.PNG

 

To achieve your desired output, please see below steps in my test.

First, create two calculated columns in source table to display percentage value of each response type and positive response.

Count response =
CALCULATE (
    COUNT ( 'Percentage in matrix'[Response] ),
    ALLEXCEPT (
        'Percentage in matrix',
        'Percentage in matrix'[Question],
        'Percentage in matrix'[Response]
    )
)

Percentage of Positive Responses =
 (
    CALCULATE (
        COUNT ( 'Percentage in matrix'[Response] ),
        FILTER (
            ALLEXCEPT ( 'Percentage in matrix', 'Percentage in matrix'[Question] ),
            OR (
                'Percentage in matrix'[Response] = "Agree",
                'Percentage in matrix'[Response] = "Strongly Agree"
            )
        )
    )
)
    / (
        CALCULATE (
            COUNT ( 'Percentage in matrix'[Response] ),
            ALLEXCEPT ( 'Percentage in matrix', 'Percentage in matrix'[Question] )
        )
    )

2.PNG

 

Create a calculated table.

New Table1 =
SUMMARIZE (
    SELECTCOLUMNS (
        'Percentage in matrix',
        "Question", 'Percentage in matrix'[Question],
        "Response", "ZPercentage",
        "CountResponse", 'Percentage in matrix'[Percentage of Positive Responses]
    ),
    [Question],
    "Response", "ZPercentage",
    "CountResponse", MAX ( 'Percentage in matrix'[Percentage of Positive Responses] )
)

3.PNG

 

Combine source table and 'New Table1'.

New Table2 =
UNION (
    SELECTCOLUMNS (
        'Percentage in matrix',
        "Question", 'Percentage in matrix'[Question],
        "Response", 'Percentage in matrix'[Response],
        "Count Value", 'Percentage in matrix'[Count response]
    ),
    'New Table1'
)

In matrix visual, drag corresponding columns from 'New Table2'.

5.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Datagrl
Regular Visitor

Here's a snapshot of my likert matrix, if it helps:

Capture.PNG

 

 

 

 

Hi @Datagrl,

 

From above snapshot of your matrix, suppose that your table view looks like:

1.PNG

 

To achieve your desired output, please see below steps in my test.

First, create two calculated columns in source table to display percentage value of each response type and positive response.

Count response =
CALCULATE (
    COUNT ( 'Percentage in matrix'[Response] ),
    ALLEXCEPT (
        'Percentage in matrix',
        'Percentage in matrix'[Question],
        'Percentage in matrix'[Response]
    )
)

Percentage of Positive Responses =
 (
    CALCULATE (
        COUNT ( 'Percentage in matrix'[Response] ),
        FILTER (
            ALLEXCEPT ( 'Percentage in matrix', 'Percentage in matrix'[Question] ),
            OR (
                'Percentage in matrix'[Response] = "Agree",
                'Percentage in matrix'[Response] = "Strongly Agree"
            )
        )
    )
)
    / (
        CALCULATE (
            COUNT ( 'Percentage in matrix'[Response] ),
            ALLEXCEPT ( 'Percentage in matrix', 'Percentage in matrix'[Question] )
        )
    )

2.PNG

 

Create a calculated table.

New Table1 =
SUMMARIZE (
    SELECTCOLUMNS (
        'Percentage in matrix',
        "Question", 'Percentage in matrix'[Question],
        "Response", "ZPercentage",
        "CountResponse", 'Percentage in matrix'[Percentage of Positive Responses]
    ),
    [Question],
    "Response", "ZPercentage",
    "CountResponse", MAX ( 'Percentage in matrix'[Percentage of Positive Responses] )
)

3.PNG

 

Combine source table and 'New Table1'.

New Table2 =
UNION (
    SELECTCOLUMNS (
        'Percentage in matrix',
        "Question", 'Percentage in matrix'[Question],
        "Response", 'Percentage in matrix'[Response],
        "Count Value", 'Percentage in matrix'[Count response]
    ),
    'New Table1'
)

In matrix visual, drag corresponding columns from 'New Table2'.

5.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yulgu-msft,

 

I realized that while it looks right and it calculates totals and percentages correctly, there is a functionality missing from this solution (my fault - I didn't mention the need because I didn't realize I would lose it).  I need to be able to filter the data with slicers based on survey dates.

 

Here is a clip of my original table, with the added columns per your instructions:

Capture.JPG

I would need to be able to somehow incorporate the Workshop End Date column in order for my matrix to be filterable by date (and other workshop info - my original matrix was connected via relationships using the date column as my unique identifier).

 

Would you be so kind as to help me again?

 

Many thanks,

 

Margot

Hi @v-yulgu-msft,

 

Sorry it took so long to get back to you.

 

Thanks so much for your response - this is exactly what I was looking for.  Your instructions were GREAT - clear and easy to use - and it worked perfectly. 

 

Thanks again! 🙂

 

~Datagrl

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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