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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
cwollett
Advocate II
Advocate II

Data model for Survey data

I work at a school that does class evaluations at the end of each term. I am trying to figure out how best to model and analyze this data and am having some issues with what I thought would be a removefilters measure. This will be a little involved, but hopefully you stick with me.

 

Data model - Dummy data

Class table with information about each class, something like:

class_idclass_namedepartment
1PSY 101 - General Psychologypsychology
2PSY 111 - Statistical Reasoningpsychology
3MATH 120 - College Algebramathematics

Instructor table like:

instructor_idinstructor_name
1John Smith
2Jane Doe
3Bob Smith

Question table, like (note that question type is important for classes with more than one instructor as course questions are asked once while the instructor questions are asked per instructor):

question_idquestionquestion_type
1Instructions were clearInstructor
2Activites were purposefulCourse
3This course challenged meCourse

Fact table sample row:

class_idinstructor_idstudent_idquestion_idresponseresponse_text
11115Strongly Agree

 

Needs/DAX Help

I want to make a visual that displays the average for an instructor compared to the average for their department.

For course-based questions, my instructor average measure is:

 

 

COURSE MEAN = 
var _responses =
# --summarizing since you do not need instructor id for course-related questions
CALCULATETABLE(
    SUMMARIZE( 
        'Fact Table'[COURSE_ID],
        'Fact Table'[QUESTION_ID],
        'Fact Table'[STUDENT_ID],
        'Fact Table'[RESPONSE]
    ),
    'Dim Questions'[QUESTION_TYPE] = "COURSE"
)
RETURN
    AVERAGEX(_responses, [RESPONSE])

 

 

 

What DAX would I need to then make something that would go in a matrix to display the above value side-by-side with the department value? I tried using the following, but it gives me the same value for both measures:

 

 

DEPARTMENT MEAN = 
var _responses =
# --summarizing since you do not need instructor id for course-related questions
CALCULATETABLE(
    SUMMARIZE( 
        'Dim Courses'[DEPARTMENT],
        'Fact Table'[QUESTION_ID],
        'Fact Table'[STUDENT_ID],
        'Fact Table'[RESPONSE]
    ),
    'Dim Questions'[QUESTION_TYPE] = "COURSE"
)
RETURN
    AVERAGEX(_responses, [RESPONSE])

 

 

If it matters, there will eventually be row-level security on the data model so that instructors only see their information. Does that mean I'm going to have to make another dimension table of data summarized per department so that it doesn't get filtered by course/instructor?

 

I would like to use this measure in more than one place, if possible. The most involved place would be a matrix that will likely include:

  • Question
  • Instructor Name
  • Class Name

I tried to do this with a calculate including remove filters (question_id, class_id) but that did not work out.

1 ACCEPTED SOLUTION

Unfortunately the ALLSELECTED option will not work because we will have row level security on the dataset, so the RLS will act as an additional filter. The only way I have found to work around the RLS issue is to create an unrelated summarized table.

View solution in original post

6 REPLIES 6
AllisonKennedy
Community Champion
Community Champion

@cwollett thanks for all the detail in your question.

 

What fields are you wanting / trying to use in your matrix? You need to consider that every field you put in the matrix adds a filter context to your measure calculation / result. So if you want a Departmental average, you need to clear all other filters coming from your matrix visual within the DAX measure itself.

 

Measure functions such as ALLSELECTED and ALLEXCEPT will be helpful for you here. Have you used those before?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Thanks for the response, @AllisonKennedy ! Great point on the visual introducing filter context. I meant to include information about the matrix I'd be using in the original message but forgot to do so. That's added now.

To answer here - I would love to be able to use this measure in two ways:

  1. A KPI/Gauge that's something like the average for the current instructor with the goal as the department average. This would then only have the instructor as an added filter.
  2. A matrix that would have expandable rows for Instructor, Class, Question.

I think the same measure would work for both, yes? Since the removal of filters on instructor_id/class_id/question_id should fufill both scenarios?

 

I have used ALLSELECTED/ALLEXCEPT in the past, yes. I didn't try either of those yet. I'll give those a try tomorrow.

@cwollett  Yes, the same measure should work for both. How did you get on with using the ALLSELECTED? Have you solved this or do you still need further guidance? 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Unfortunately the ALLSELECTED option will not work because we will have row level security on the dataset, so the RLS will act as an additional filter. The only way I have found to work around the RLS issue is to create an unrelated summarized table.

Anonymous
Not applicable

Hi @cwollett ,

Glad to hear you may have found a solution! If you're sure the issue has been resolved, could you mark this post as resolved? That way, others with similar issues can more easily find a solution and the community can see that the issue has been resolved.
Thanks, and if you need any further help, please feel free to contact

@cwollett yes, RLS makes things a bit tricky - there's no way I'm aware to clear the RLS filters without creating a different field. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.