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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
klontok
New Member

Create new table with percent of respondents for each category

I have an unpivoted table of survey data where respondents could choose more than one of several options.

 

Survey IDInfectionResponse
0001SinusitisSelected
0001SepsisSelected
0002PneumoniaSelected
0003SepsisSelected
0003PneumoniaSelected

 

I would like to create a table that shows the percent of respondents that chose each infection.

Infection% of respondents
Sinusitis33%
Sepsis66%
Pneumonia66%

 

I tried using SUMMARIZE, but I can't seem to get the correct denominator. The COUNTDISTINCT below counts only the distinct Survey IDs within the infection category instead of in the entire table, so I get 100% for every type of infection. Maybe SUMMARIZE is the wrong way to go? Thanks in advance for any help! 

 

Table = SUMMARIZE('Infections Prior to Diagnosis', 'Infections Prior to Diagnosis'[Infections],"Percent of respondents",DIVIDE(COUNT('Infections Prior to Diagnosis'[Response]),COUNTDISTINCT('Infections Prior to Diagnosis'[Survey ID])
)
2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

This question is much more complex than you might think, but here is a simplistic approach that takes some liberties.

 

lbendlin_0-1707350488547.png

 

View solution in original post

v-kongfanf-msft
Community Support
Community Support

Hi @klontok ,

 

If you want to create a calculation table, I have made a modification on the formula you provided, refer below:

Table_ = 
SUMMARIZE(
    'Infections Prior to Diagnosis',
    'Infections Prior to Diagnosis'[Infection],
    "Percent of respondents",
    DIVIDE(
        CALCULATE (
            COUNTROWS('Infections Prior to Diagnosis'),
            FILTER(
                ALL('Infections Prior to Diagnosis'),
                'Infections Prior to Diagnosis'[Infection] = VALUES('Infections Prior to Diagnosis'[Infection])
            )
        ),
        CALCULATE(
            DISTINCTCOUNT('Infections Prior to Diagnosis'[Survey ID]),
            ALL('Infections Prior to Diagnosis')
        )
    )
)

vkongfanfmsft_1-1707380411897.png

 

Best Regards,
Adamk Kong

 

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

3 REPLIES 3
v-kongfanf-msft
Community Support
Community Support

Hi @klontok ,

 

If you want to create a calculation table, I have made a modification on the formula you provided, refer below:

Table_ = 
SUMMARIZE(
    'Infections Prior to Diagnosis',
    'Infections Prior to Diagnosis'[Infection],
    "Percent of respondents",
    DIVIDE(
        CALCULATE (
            COUNTROWS('Infections Prior to Diagnosis'),
            FILTER(
                ALL('Infections Prior to Diagnosis'),
                'Infections Prior to Diagnosis'[Infection] = VALUES('Infections Prior to Diagnosis'[Infection])
            )
        ),
        CALCULATE(
            DISTINCTCOUNT('Infections Prior to Diagnosis'[Survey ID]),
            ALL('Infections Prior to Diagnosis')
        )
    )
)

vkongfanfmsft_1-1707380411897.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

This question is much more complex than you might think, but here is a simplistic approach that takes some liberties.

 

lbendlin_0-1707350488547.png

 

Thank you so much! I was assuming I had to create another table, but the measure actually works better for my purposes because the slicers filter it. 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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