Default value based on previous question

Can a variable has value 0 if the previous question answers was no and the subsequent question was not asked .

For example,
q1. For any ailment, were you hospitalized for any daycare or as an inpatient procedure in the last 365 days? yes-1 , no-0
q2. How many times you were hospitalized? (this is answered if person says yes) (this question has integer type)

I want a default value 0 for q2 if person says no in q1

Hi @archanadang,
You can use calculation (yellow highlighted) for the data that you want. You can follow the below one:

Hope it will be helpful for you.

1 Like

@mdarshad17, :clap: :heart: :partying_face:

Hi, I am using this question in repeated group. Its not working. It is showing an error. Please see the attached file.
Book3.xlsx (14.1 KB)

@mdarshad17 Hi, I am using this question in repeated group. Its not working. It is showing an error. Please see the attached file.
Book3.xlsx (14.1 KB)

@mdarshad17 @Kal_Lam it is not working.

Hi @archanadang,
You did the right thing. But just a little typo was there. Please check the highlighted area of below image:

1 Like

Thanks alot @mdarshad17 . It worked.

Can I ask a follow up question? I want to fetch details from block3 to block9 for example, if member 1 says that he was hospitalised 2 times, then block 9 should open twice for him(with his name and person ID appearing in block9 questions) and if member 2 says once, block 9 should open once for him (with his name and person ID appearing in block 9 questions).
I am attaching what I did.
Book3 (1).xlsx (14.0 KB)