I have a data table that contains answers to questions from a form. I am trying to pivot the data in an Analysis to show the questions as columns and the corresponding answers in rows. I do not have access to modify the dataset so I need to use calculated fields in the analysis.
Here is rough simplification of my source data:
form_id
question
answer
12345
Location
San Diego
12345
Priority
2
12345
Project Title
Project 1
12345
Region
West
54321
Location
Devens
54321
Priority
2
54321
Project Title
Project 2
54321
Region
Central
abcxyz
Location
New Brunswick
abcxyz
Priority
4
abcxyz
Project Title
Project 3
abcxyz
Region
East
This is roughly what I want to achieve:
Project Title
Location
Priority
Region
Project 1
San Diego
2
West
Project 2
Devens
2
Central
Project 3
New Brunswick
4
East
The form_id is the key column to match the answers between the different questions. In DAX I could write a custom formula to lookup the corresponding values but I have not found any equivalent lookup in QS. The closest I have gotten is by using firstValue in a calculated field like:
You can transform your form data into a pivoted table in Amazon QuickSight by creating specific calculated fields for each question type and using conditional functions. This approach allows you to extract specific answers for each question type per form_id without modifying the underlying dataset [.
Creating Calculated Fields for Each Question Type
Step 1: Create Individual Calculated Fields
For each question type, create a separate calculated field using the ifelse() function: