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
Anonymous
Not applicable

calculate the % yes response based on the sub-question answers

Hi,

 

I have a table with the survey questions and answers loaded from the SQL database.

 

There are 10 questions in total within the survey. (This number is fixed).

 

Under each question, there are item lists attached to it, and the item list varies among different surveys completed.

 

For example, for survey completed with a survey ID A1 (Survey ID to distinguish different surveys completed), there are 5 items asked for Q1, whereas survey ID A2, there are 3 items asked for Q1.

 

For each item we asked, there are sub-questions to them, and the answer to sub-questions should be either yes or no. I create a scoring system to look at the answers to each sub-question under each item - I will get mark only if my answer to each sub-questions is yes under each item. 

 

The number of sub-questions will be the same under the same question group.

 

For example, there are always 3 sub-questions under Q1 for each item I asked in each survey, and there are always 2 sub-questions under Q2 for each item I asked in each survey.

 

Example of surveys data:

 

Survey IDQuestionItemSub QuestionAnswer
A1Q1Xq1Yes
A1Q1Xq2No
A1Q1Xq3No
A1Q1Yq1Yes
A1Q1Yq2Yes
A1Q1Yq3Yes
A1Q2Xq1No
A1Q2Xq2No
A1Q2Yq1Yes
A1Q2Yq2Yes
A2Q1Xq1Yes
A2Q1Xq2Yes
A2Q1Xq3Yes
A2Q2Yq1No
A2Q2Yq2Yes

 

 

Above is an example of the data I loaded from the database.

 

Assume Q1 and Q2 both worth 10 marks.

The score for each Survey should be:

 

Survey A1: For Q1, I get 5 marks. For item X, I get 1 Yes out of 3 sub-questions, therefore it does not count; for item Y, I get 3 yes out of 3 sub-questions, therefore it counts. I get the mark for 1 item out of 2 items, thereby scoring 5 marks out of 10.

 

Similarly, for Q2, I do not get the mark for item X, but I get the mark for item Y, so I get 5 marks for Q2.

 

My total score for Survey A1 is therefore 10 marks out of 20 marks.

 

Survey A2: Based on the same logic, I get 10 marks out of 20 marks.

 

Could anybody suggest a way to construct the formula/new tables in order to achieve my goal?

 

Thanks in advance!

 

 

 

 

 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

After my test, you could try to use this formula to create a measure:

Result =
VAR _table =
    SUMMARIZE (
        Table1,
        Table1[Survey ID],
        Table1[Question],
        Table1[Item],
        "_marks", IF (
            CALCULATE (
                COUNTA ( Table1[Answer] ),
                FILTER ( Table1, Table1[Answer] = "Yes" )
            )
                = CALCULATE ( COUNTA ( Table1[Answer] ) ),
            1,
            0
        ) * 10
            / CALCULATE (
                DISTINCTCOUNT ( Table1[Item] ),
                ALLEXCEPT ( Table1, Table1[Survey ID], Table1[Question] )
            )
    )
RETURN
    SUMX ( _table, [_marks] )

Result:

5.JPG

 

and here is pbix file, please tyr it.

 

Best Regards,
Lin

 

Community Support Team _ Lin
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

1 REPLY 1
v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

After my test, you could try to use this formula to create a measure:

Result =
VAR _table =
    SUMMARIZE (
        Table1,
        Table1[Survey ID],
        Table1[Question],
        Table1[Item],
        "_marks", IF (
            CALCULATE (
                COUNTA ( Table1[Answer] ),
                FILTER ( Table1, Table1[Answer] = "Yes" )
            )
                = CALCULATE ( COUNTA ( Table1[Answer] ) ),
            1,
            0
        ) * 10
            / CALCULATE (
                DISTINCTCOUNT ( Table1[Item] ),
                ALLEXCEPT ( Table1, Table1[Survey ID], Table1[Question] )
            )
    )
RETURN
    SUMX ( _table, [_marks] )

Result:

5.JPG

 

and here is pbix file, please tyr it.

 

Best Regards,
Lin

 

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

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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