When I use pulldata() or instance() functions with nested if statement as below, it does not work

Hello , I want to preload data for a specific district depending on the name of a district in the previous question (1. What district do you come from?)

The data being loaded from the external files are very large, For each district its between 150,000 to 400,0000 so that’s the reason why each district has its on external file

When I use pulldata() or instance() functions with nested if statement as below, it does not work.

Is there an alternative function? a way around this,
Again, Remember I am preloading large external files for each district

if(${district}='district2',(pulldata('district2','longitude','id_key', ${id_key_j})),
if(${district}='district3',(pulldata('district3','longitude','id_key', ${id_key_j})),
if(${district}='district4',(pulldata('district4','longitude','id_key', ${id_key_j})),
if(${district}='district5',(pulldata('district5','longitude','id_key', ${id_key_j})),
if(${district}='district6',(pulldata('district6','longitude','id_key', ${id_key_j})),
if(${district}='district7',(pulldata('district7','longitude','id_key', ${id_key_j})),
if(${district}='district8',(pulldata('district8','longitude','id_key', ${id_key_j})),
if(${district}='district9',(pulldata('district9','longitude','id_key', ${id_key_j})),
if(${district}='district10',(pulldata('district10','longitude','id_key', ${id_key_j})),
if(${district}='district11',(pulldata('district11','longitude','id_key', ${id_key_j})),
if(${district}='district12',(pulldata('district12','longitude','id_key', ${id_key_j})),
if(${district}='district13',(pulldata('district13','longitude','id_key', ${id_key_j})),
if(${district}='district14',(pulldata('district14','longitude','id_key', ${id_key_j})),
if(${district}='district15',(pulldata('district15','longitude','id_key', ${id_key_j})),
if(${district}='district16',(pulldata('district16','longitude','id_key', ${id_key_j})),

@stephenoduor, could you share a sample (a small portion of your dummy CSV file and the XLSForm) so the community could also play around to provide you with a workaround?

There is a syntax error: district15, ’ is missing at the end. See the changing colour format.

1 Like

Thanks @Kal_Lam , but even with correction still not working

@stephenoduor, did you also try to look at the advice shared by @wroos?

What error do you get?
Did you check the form with the online validator?

Hello @Kal_Lam , Yes I did but still not working

It might also be preferable to reduce the external files to the minimum of variables you really need.