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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
thmpsne
Frequent Visitor

Survey Data - Unpivoting Causing Issues?

Hi everyone, 

This is my first time posting so please forgive me if it's rough! 

I'm relatively new to PowerBI, and my DAX is very basic. In my role, we are moving toward using PowerBI to present results of university student experience surveys (social science data). These surveys are administered through Qualtrics. The surveys are very customisable, and even the pathway that a respondent takes through the survey will differ conditionally based on their unique responses (e.g. they won't get prompted to answer questions about employment if they have already indicated that they aren't employed). Thus, my dataset is highly variable.

 

Despite the challenges, I'm able to do most of what I want, but have continually run into the issue that I'm presenting here. 

 

I have unpivoted my data; prior to unpivoting, depending on respondents, there could be over 100 columns (question responses) per unique ID, for >3000 respondents. Please see a dummy and highly simplified sample below of what the data sort of looks like:

 

Student IDQuestion CodeResponse Value
123456789example_numberjobs2
123456789example_mainrole - Job TitleTeacher
123456789example_industryEducation & Training
123456789example_employtypeWorking for an employer
123456789example_employedoverallYes, employed at time of survey
123789456example_numberjobs2
123789456example_mainrole - Job TitleNurse
123789456example_industryHealthcare & Social Assistance
123789456example_employtypeWorking for an employer
123789456example_employedoverallYes, employed at time of survey
321654987example_employedoverallNo, not employed at survey time
456123789example_employedoverallNo, not employed at survey time
987654321example_numberjobs1
987654321example_mainrole - Job TitleCivil Engineer
987654321example_industryConstruction
987654321example_employtypeSelf-Employed
987654321example_employedoverallYes, employed at time of survey

 

I think I need a measure that says something like: Based on Question Code "example_industry", return the count of Response Value in the corresponding row (for each unique student ID that has answered that question). Also, in this scenario I would be looking at Count, but occasionally I would need to return the Average.

 

How do I write a measure to parse out responses for "example_industry"; e.g. I want to create a table like: 

 

Construction1
Education & Training1
Healthcare & Social Assistance1
Total3

 

 

I also know I can't just use visual level filters to solve this, as a whole dashboard of visualizations created using visual level filters doesn't 'work' - when you click and interact with one figure, each Visualization's filters contradict and no data is shown. I tried this already! 

 

 

Currently I've gotten past the need to figure out how to do this by creating separate data tables but it's becoming increasingly apparent that is not a sustainable solution. 

 

SOS! Please help! 

 

Thanks in advance Smiley Happy 

 

 

EDIT

I used measure: 

Industry countx = COUNTX(FILTER('Employment Table', 'Employment Table'[Code]="gds_industry"), 'Employment Table'[Value]), which does work and I am able to create a bar chart of industry, but other visualisations created using measures from the same table and column 'go blank' when you click on one of the Industries, to filter the other page's visualizations... Anyway to avoid this?!
1 ACCEPTED SOLUTION

@thmpsne 

Just testing againts your sample I created a couple measures.

Student Count = DISTINCTCOUNT ( 'Table'[Student ID] )
Industry = 
CALCULATE( [Student Count],
'Table'[Question Code] = "example_industry")
Job Title = 
CALCULATE( [Student Count],
'Table'[Question Code] = "example_mainrole - Job Title")

They work when you apply filters on say the student so it should work with filtering on other columns in your data as well.

surevey.jpg

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi,

Check if this measure helps:

Survey Measure = 
VAR v_SurveyCnt = CALCULATE
( 
    DISTINCTCOUNT( SurveyData[Student ID] ), 
    ALLEXCEPT( SurveyData, SurveyData[Question Code], SurveyData[Response Value] ) ,
    FILTER( SurveyData, SurveyData[Question Code]="example_industry" )
 )
 RETURN
 v_SurveyCnt

result.PNG

Thanks.

Hi @Anonymous  - This 'works' but doesn't return the correct values when I use it in my actual dataset. 

It also doesn't solve the issue of filtering values that are in the same column as values for other visualisations. 

@thmpsne 

Just testing againts your sample I created a couple measures.

Student Count = DISTINCTCOUNT ( 'Table'[Student ID] )
Industry = 
CALCULATE( [Student Count],
'Table'[Question Code] = "example_industry")
Job Title = 
CALCULATE( [Student Count],
'Table'[Question Code] = "example_mainrole - Job Title")

They work when you apply filters on say the student so it should work with filtering on other columns in your data as well.

surevey.jpg

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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