How to Carry Forward subset of drilldown options for matrix questions | XM Community
Solved

How to Carry Forward subset of drilldown options for matrix questions

  • 20 April 2023
  • 4 replies
  • 124 views

Badge +2

So what I have is a drill down hierarchy of

Region > Park > Entrance

The users will select a Region and a Park for the first question. What I then need is for the entrances to carry forward as the statement options for a matrix question.

https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/question-types-guide/specialty-questions/drill-down/

The help provided in the drill down guide above only provides a way to carry forward the selected park or region, but not the entrances associated with the selected park.

Is there a way to carry forward drill down options that haven’t been asked without writing loads of conditional display logic questions?

Thanks!

icon

Best answer by ThomasW_IronMountain 1 May 2023, 20:57

View original

4 replies

Userlevel 4
Badge +14

Could you use piping rather than carry forward in your matrix question?

e.g. ${q://1_QID306/ChoiceGroup/SelectedAnswers/3}

Userlevel 5
Badge +24

@MatthewJay , how comfortable are you with Javascript?  There is a way to do this but it would require a tad bit of Javascript. Some people might prefer to tackle the conditional formatting route. I also like @MikeW ‘s recommendation to use display logic and piping. 

But here is another way to do it. Use Embedded Data to store the selected Park and Region, and then use that information to dynamically populate the matrix question with the corresponding entrances.

Here's how you can do it:

  1. Create a new Embedded Data field called "SelectedPark" and another called "SelectedRegion". These fields will be used to store the selected Park and Region values, respectively.

  2. In the first question, where the user selects the Region and Park, add some JavaScript to store the selected values in the Embedded Data fields. For example:
     

    Qualtrics.SurveyEngine.addOnload(function() {
        var selectedPark = "${q://QID1/SelectedChoices}";
        var selectedRegion = "${q://QID2/SelectedChoices}";

        Qualtrics.SurveyEngine.setEmbeddedData("SelectedPark", selectedPark);
        Qualtrics.SurveyEngine.setEmbeddedData("SelectedRegion", selectedRegion);
    });

  3. In this example, QID1 is the question where the user selects the Park, and QID2 is the question where the user selects the Region. The JavaScript code retrieves the selected values and stores them in the Embedded Data fields.

  4. Create the matrix question where you want to display the entrances. In the question editor, click on the "Advanced Question Options" button and then select "Add JavaScript".

  5. In the JavaScript editor, add the following code:
     

    Qualtrics.SurveyEngine.addOnload(function() {
        var selectedPark = "${e://Field/SelectedPark}";
        var selectedRegion = "${e://Field/SelectedRegion}";

        var entranceChoices = [];

        // Replace this with your own code to dynamically generate the entrance choices based on the selected Park and Region.
        // For example, you could use an API call to retrieve the entrances for the selected Park and Region.
        // This example code just hard-codes some sample entrance choices.
        if (selectedPark == "Park A" && selectedRegion == "Region 1") {
            entranceChoices = [
                { value: "Entrance A1", text: "Entrance A1" },
                { value: "Entrance A2", text: "Entrance A2" },
                { value: "Entrance A3", text: "Entrance A3" }
            ];
        } else if (selectedPark == "Park B" && selectedRegion == "Region 2") {
            entranceChoices = [
                { value: "Entrance B1", text: "Entrance B1" },
                { value: "Entrance B2", text: "Entrance B2" }
            ];
        }

        // Set the matrix question choices to the dynamically generated entrance choices
        Qualtrics.SurveyEngine.setEmbeddedData("EntranceChoices", JSON.stringify(entranceChoices));
        this.questionChoices = entranceChoices;
    });
     

    This JavaScript code retrieves the values stored in the Embedded Data fields for the selected Park and Region, generates the entrance choices based on those values, and sets the matrix question choices to those dynamically generated entrance choices.

    Note that this example code just hard-codes some sample entrance choices for demonstration purposes. You'll need to replace the code with your own code to dynamically generate the entrance choices based on the selected Park and Region.

    With this approach, the matrix question will dynamically display the entrance choices based on the selected Park and Region without the need for conditional display logic questions.

Badge +2

Thank you @MikeW and @ThomasW_IronMountain for your responses. I really appreciate your feedback!

I’ve been trying to avoid Mike’s solution because it would create over 200 conditional display logic questions.

 

Thomas, I’m not strong in JS, but I suspected I would be going down this path.

If I’m understanding your solution correctly, the idea is to hard code the conditional logic behind the scenes, so that only a single question is created?

I’m going to give it a shot, although I am curious if there would be anyway to reference the table from the drill down question. I think you hinted that this would be possible through an API call. I’m not really strong in the qualtrics engine either. If this is possible, could you point me in a direction to learn more about how this might work.

Thanks again.

 

Userlevel 5
Badge +24

@MatthewJay ,the idea uses embedded data to capture the values for “Region” and “Park” and then once you put in the entrances into JS for each Region/Park combination it will automatically tie your “Region/Park” combination to the entrance options and display those. Yes, you can use an API call to retrieve the entrances for the “Region/Park” combination. This would be an API call called “Excel REST API”.  Is there anyone is your organization that is proficient at Javascript? It would be faster to get some guidance on this. If not, you can also try a third party integration company like Red Pepper.  OR you can self-teach yourself using online resources (and this community of course!).  Here are the basic steps to follow: 

  1. First, you need to get the URL of the Excel file that you want to access. You can store the file in OneDrive or SharePoint or another cloud-based storage service that supports the Excel REST API.

  2. Next, you need to create an Excel session by sending a POST request to the sessions endpoint of the Excel REST API. The request should include the URL of the Excel file in the body.

  3. Once you have created a session, you can use the worksheets endpoint to get a list of the worksheets in the Excel file. You can then use the tables endpoint to get a list of tables in a particular worksheet.

  4. To retrieve data from a table, you can use the range endpoint. You specify the range of cells that you want to retrieve, and the API returns the values in those cells.

Here are some resources that you can use to learn more about the Excel REST API and how to use it to retrieve data from an Excel file:

Leave a Reply