Populate embedded value based on previous questions and csv data | XM Community
Skip to main content

Hi,

I have a study that looks into population group sizes based on a participant’s reported state and county. I have a large csv which contains every US state and county combination with corresponding subpopulation values (let’s use group A, group B, and group C for now).

After reading through examples, I am able to use the responses from a drill down to set the state and county as embedded values and feed these values into the next series of questions. As an fyi, the drill down question was copied from a previous study so it is not linked directly to the csv I have. 

What I am stuck on now is how to use the embedded state and county values to correctly filter the csv to set corresponding groups A, B, and C embedded values which will be piped into a text. If this csv is loaded as a contact list, is there a way to set embedded values without using an authenticator? Is there some clever JS workaround? Any advice will be welcome. Thank you for your help.

Rather then uploading your csv as contact list, I would suggest try using supplemental data to fetch the group values as needed.

Link for your reference: Autocomplete Questions & Supplemental Data (qualtrics.com)

If you are keen to use csv as contact list then webservice to be used to fetch infomration from XMD i.e., keeping country value in ExternalDataReference and search the contact and fetch rest of the values

Link for reference: 

api.qualtrics.com/c79e78a949572-search-directory-contacts

api.qualtrics.com/dd105bd826317-get-directory-contact

 


Hi @Appzk ,

Thank you for the suggestion. I checked with the administrator for the work I account I have and unfortunately, we do not have the ability to add the “imported data” function to be able to use the supplemental data option.

I’m not keen on using a contact list; I just don’t know how else to approach the problem. If you have any suggestions or tips to make this easier, please let me know. Thank you!


@44RK44,

The best solution would be to import the csv into a database table on a web server and use a web service to retrieve the state/country info and populate embedded data fields.

Without that, you could convert the csv to a JS object, and use JS to do a lookup and set embedded data fields. 


Hi @44RK44 ,

 I can provide an example that is similar to your requirement. Let's say you have a textbox where users enter their zip code. Based on the entered zip code, you need to validate it against a database of valid US zip codes (similar to the USPS website). Once the validation is successful, I wanted to retrieve additional data such as the State, Region, DMA, and DMA code, and perform logical operations using that data.

For instance, let's imagine a user enters the zip code "90210." The system will validate this zip code against the database and confirm its validity in real time. Then, it will retrieve the associated data for that zip code, such as the State (California), Region (West Coast), DMA (Los Angeles), and DMA code (803) in embedded data and use this retrieved information to perform various logical operations or display relevant content to the user.

I am achieving the same using similar idea to that of @TomG  where I have made an object of that zip code data as below 

{    "Zip_code": "03583", 
"State": "New Hampshire",
"DMA": "500",
"DMA_Name": "PORTLAND-AUBURN",
"Region_Code": "1",
"Region": "NorthEast"
},



You can create object similar to this having population of State and county and store it in embedded variable and perform the necessary logical operations.
Hope this resolves your query😊!


Hi @qualtrics_nerd  and @TomG,

I think my best bet is to create a JS object from the csv; I can do this pretty easily. Once this JS object is created, where do I store it in order to create the conditional logic to pass the correct embedded values into the next question? 


Hi @qualtrics_nerd  and @TomG,

I think my best bet is to create a JS object from the csv; I can do this pretty easily. Once this JS object is created, where do I store it in order to create the conditional logic to pass the correct embedded values into the next question? 

Use JS to store the values in embedded data fields:

Qualtrics.SurveyEngine.setEmbeddedData("Population",jspopvar);

 


Hi again, @TomG,

Sorry, I should have been more clear. I understand how to created embedded data. I’m unclear on what to do with the csv turned JS object. So, each line of the the csv will be turned into a JS object and then presumably all stored in one large array. Do I copy this array directly into the survey using Qualtrics.SurveyEngine.addOnload()? 


Hi again, @TomG,

Sorry, I should have been more clear. I understand how to created embedded data. I’m unclear on what to do with the csv turned JS object. So, each line of the the csv will be turned into a JS object and then presumably all stored in one large array. Do I copy this array directly into the survey using Qualtrics.SurveyEngine.addOnload()? 

Yes, that’s one way to do it:

Qualtrics.SurveyEngine.addOnload(function() {
    stateCounty = C
       /*objects with state, county, population, etc. go here*/
    ];
});

Another way would be to upload your csv to Qualtrics, and then get the data into your array with ajax.


Ok, I think I have a good understanding of what to do. Thank you all for your help!


Leave a Reply