We are creating a survey for facilities in our City Parks. The number of facilities and the items to be inspected varies from park to park. One park may have two facilities with six assets (rooms) to inspect while another park may have three facilities with 10 assets to inspect. We would like to be able to populate the repeat_count for facilities based on how many are at a give park and we would like to do this for the repeats for assets and items to inspect.
list name name label park_name_list
facility_name | AQUATIC_CENTER | Aquatic Center | CACTUS |
facility_name | RESTROOMS | Restrooms | CACTUS |
facility_name | COMMUNITY_CENTER | Community Center | ELDORADO |
facility_name | AQUATIC_CENTER | Aquatic Center | ELDORADO |
facility_name | SOUTH_BUILDING | South Building | ELDORADO |
facility_name | AQUATIC_CENTER | Aquatic Center | CHAPARRAL |
facility_name | PARK_OFFICES | Park Offices | CHAPARRAL |
facility_name | RESTROOMS | Restrooms | CHAPARRAL |
How can I count the number of facilities by park in the above example and then count the number of assets by by facility name from below
list name name label park_name_list facility_name_list
asset_name | COMMUNITY_ROOM_1 | Community Room #1 | ELDORADO | COMMUNITY_CENTER |
asset_name | KITCHEN | Kitchen | ELDORADO | COMMUNITY_CENTER |
asset_name | MENS_ROOM | Men's Room | ELDORADO | COMMUNITY_CENTER |
asset_name | WOMENS_ROOM | Women's Room | ELDORADO | COMMUNITY_CENTER |
asset_name | POTERY_ROOM | Pottery Room | ELDORADO | COMMUNITY_CENTER |
asset_name | CLASSROOM_3 | Classroom #3 | ELDORADO | COMMUNITY_CENTER |
asset_name | OFFICES | Offices | ELDORADO | COMMUNITY_CENTER |
asset_name | HALLWAYS_LOBBY | Hallways/Lobby | ELDORADO | COMMUNITY_CENTER |
asset_name | ENTRANCE | Entrance | ELDORADO | COMMUNITY_CENTER |
asset_name | GYM | Gym | ELDORADO | COMMUNITY_CENTER |
asset_name | OFFICES | Offices | ELDORADO | AQUATIC_CENTER |
asset_name | MENS_LOCKER_ROOM | Men's Locker Room | ELDORADO | AQUATIC_CENTER |
asset_name | WOMENS_LOCKER_ROOM | Women's Locker Room | ELDORADO | AQUATIC_CENTER |
asset_name | MENS_ROOM | Men's Room | ELDORADO | SOUTH_BUILDING |
asset_name | WOMENS_ROOM | Women's Room | ELDORADO | SOUTH_BUILDING |
We are able to limit the choices by using a choice_filter like this for facilities
park_name_list=${park_name} and facility_name_list=${facility_name}
and this for assets
park_name_list=${park_name} and facility_name_list=${facility_name} and asset_name_list=${asset_name}
select_one park_name | park_name | Park |
select_one_external facility_name | facility_name | Facility |
begin repeat | Facility_Locations | Locations |
select_one_external asset_name | asset_name | Assets |
begin repeat | Inspections | Inspections |
select_one_external inspection_item | inspection_item | Item |
select_one inspection_rating | inspection_rating | Inspection Rating |
text | notes | Notes |
select_one yes_no | work_order_submitted | WO Submitted |
select_one yes_no | work_order_completed | WO Completed |
image | Inspections_image | Image |
end repeat | ||
end repeat | ||
integer | asset_count | Assets |
Thanks Mele
Solved! Go to Solution.
Hi. I cannot think of an obvious way to count list elements using an XLSForm expression. Could you create a CSV file listing the facility count? If so, you could use the pulldata function later to get the value and apply it to the repeat_count. Same for the assets.
Hi. I cannot think of an obvious way to count list elements using an XLSForm expression. Could you create a CSV file listing the facility count? If so, you could use the pulldata function later to get the value and apply it to the repeat_count. Same for the assets.
Ismael,
I was struggling to find a way to do this and one thought I up with after other attempts, was to do what you suggest with pulldata. I wanted to see if I was missing something, but it sounds like that what you suggest will give us what we want.
Thanks for the response and your suggestion on how to tackle this