GENERATE RANDOMISE DATE FOR TEST | XM Community
Skip to main content

GENERATE RANDOMISE DATE FOR TEST

  • September 28, 2022
  • 6 replies
  • 24 views

Forum|alt.badge.img+4

Hello,
is-it possible to generate randomise data and how ?
i want check my survey filters.
Thanks for help

6 replies

Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • 1555 replies
  • September 28, 2022

Mor_lvdc
You cannot generate it OOTB, but by creating 3 random numbers in 3 different embedded dataand creating it in a manner like (22-22-2022) manually or you can include the below JS which will do the work for you.
"Qualtrics.SurveyEngine.addOnload(function()
{
function randomDate(start, end) {
 var date;
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
}
const d1 = randomDate(new Date(2012, 0, 1), new Date());
var d = d1.toISOString().substring(0, 10);
Qualtrics.SurveyEngine.setEmbeddedData("date",d);
});"
Just create an embedded data "date" in your survey flow and it will be populated.

Hope this helps!


Forum|alt.badge.img+4
  • Author
  • QPN Level 2 ●●
  • 14 replies
  • September 28, 2022

that will create data for my variables ?
and how i incorporate the js?


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • 1555 replies
  • September 28, 2022

Mor_lvdc
I thought you wanted random dates (as in your title) and not random data
The JS will create randomized dates and populate the variable "date" for you. You can include JS as mentioned here (Add JavaScript (qualtrics.com)).
If you want to generate test data for your survey you can follow this support page.
Hope this helps!


Forum|alt.badge.img+4
  • Author
  • QPN Level 2 ●●
  • 14 replies
  • September 28, 2022

Sorry mistake on my title :)
thanks a lot for your answer.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6083 replies
  • September 28, 2022

Mor_lvdc,
Yes, you can generate random test data. See:
Generate Test Responses


SuhasM
Qualtrics Employee
Forum|alt.badge.img+16
  • Qualtrics Employee
  • 114 replies
  • September 29, 2022

Looks like both Deepak and TomG arrived at the same solution with the support page! Thank you guys for incredible contributions to the community! 😊