Fill a text field with a preset value based on the selected value of a list in XLS Forms - xlsx

I am building an xlsx form for ODK. I have a dropdown list and a text-input field. I would like when I select a value from the ListA, a specific code to be filled in the text-input field.
For example if I choose "valueA" from the dropdown list the value "codeA" to appear in the text-input.
Currently I have an excel sheet with all the matches between the values in ListA and the corresponding codes (around 300). All the values in ListA are unique.
I was making some tests trying to use the "Calculation" field of Xls but no success till now.
Has anyone done something like that with Xls? Is it possible?

You could include a calculate field between the dropdown list and the text-input where you pull values from a csv file with the correspondence between valueA and codeA using the value selected in ValueA as a key. You can find an explanation of how the pulldata(...) calculation works here.
Here goes a brief example. In the survey tab:
|type |name |label |calculation|
|select_one keys|value_a|Value A | |
|calculate |code_a | |pulldata('data', 'value_column', 'key_column', ${value_a}|
|note |note |Code A value: ${code_a}| |
In the choices tab:
|list_name|name |label |
|keys |valueA_1|valueA_1|
|keys |valueA_2|valueA_2|
(.......)
And the file data.csv should look like this:
|value_column|key_column|
|valueA_1 |codeA_1 |
|valueA_2 |codeA_2 |
(.......)
Finally, I would advice to consider applying a cascade selection layout in value_a, because selecting one out of 300 values can be challenging. Another option could be sorting these choices alphabetically or in a different order, such that when someone fills-in your form she will know how to easily locate the appropriate choice.
Hope this helps!

Related

EXCEL - pulling unique values from a range that fit specific criteria

I am using the following array formula in excel to pull unique values from a range.
{=INDEX($N$2:$N$21, MATCH(0,COUNTIF($A$385:A399, $N$2:$N$21), 0))}
That works fine, however I want to pull specific values based on criteria.
The data I am working with is formatted as: | Names | Team | Site | Date | and I want to pull unique values from the names column that match my team and site criteria within a date range.
I am getting the date range with the following:
{=CELL("address",INDEX($A2:$D50000,MATCH(TRUE,$D2:$D50000>=$B$1,0),4))}
reversing for end date, then using those values to populate my index / countif ranges in my first formula with INDIRECT. Again, this is all working. I just can't seem to get my criteria to work to make my unique values only pull when part of X team and Y site.
Any help to point me in the right direction would be appreciated.

Add label to node from a CSV file in NEO4J

I am trying to add some nodes to my graph database from a CSV, which suppose is like:
| city continent feature_1 ...
|--------------------------------------------------
0 | Barcelona Europe
1 | Stockholm Europe
2 | New York America
3 | Nairobi Africa
4 | Tokyo Asia
The first approach was to simply load this data as:
// Insert city nodes
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM 'file:///city_data.csv' AS row
MERGE (city: City {name: row.city})
Next step was to incorporate the continent information, so I could have nodes of different colors. This means having two labels for each node, which is something I am not sure how to do. Anyway, for the moment I decided to simply have one label instead, which contained the continent information. Since this information is within the CSV file I believe apoc.create.node tool is the way to go. Hence, inspired by How to use apoc.load.csv in conjunction with apoc.create.node I tried the following:
CALL apoc.load.csv('file:///city_data.csv') YIELD row
CALL apoc.create.node(['row.continent'], {name:['row.continent']}) YIELD node
RETURN count(*)
This does not raise any error, but it does something different from what I was thinking of. It basically sets the column name ("row.continent") itself as the label...
The problem is that you surround the variable in apostrophes, so try this:
CALL apoc.load.csv('file:///city_data.csv') YIELD row
CALL apoc.create.node([row.continent], {name: row.continent}) YIELD node
RETURN count(*)

Assign rows to category in Openrefine

I have a dataset like this, and I'm looking for a way to add a category, based on what kind of product I have.
Can I search for Apple + Orange and assign them to a category named Fruits, and similar with Milk + Wine and assign them to another category, named Drinks?
| Item | Category |
|-------|----------|
| Apple | | <-- Fruits
| Orange| | <-- Fruits
| Milk | | <-- Drinks
| Wine | | <-- Drinks
Or maybe a simpler method: find any rows containing Milk and assign them to category Drinks?
This is something you can do without code.
Filter or facet in the Item field for each value
Create a facet on the Category field
Click the edit button next to the blank value in the Category facet and type with the category you want to add.
Edit your Item facet or filter to move to the next category and repeat this process until you have categorized all yours items.
As magdmartin says you can do this using facets and edits - the solution he describes is probably the simplest approach and least error prone. However, if you prefer to do in a single step you can use GREL to test the content of the Item cell and then set the value in the Category cell dependent on the content of the Item cell.
with(cells["Item"].value.toLowercase(),w,if(or(w=="orange",w=="apple"),"Fruits",if(or(w=="milk",w=="wine"),"Drinks","")))
This is the same approach as given by Ettore Rizza above but in GREL rather than Jython.
magdmartin and Owen Stephens give good answers. Another simple way using GREL:
From the options dropdown for your 'Item' choose Edit column > Add column based on this column...
New column name 'Category' and in the expression set:
value.replace("Apple","Fruit").replace("Orange","Fruit").replace("Milk","Drink").replace("Wine","Drink")
You could keep adding .replace("whatever food","whatever category") ad nauseum

Array formula having unique values for Data Validation dropdown without using helper column

I am trying to create an array defined name to enter into a data validation dropdown without using any helper columns in the sheet.
I have a table containing one of the column headers called 'List' which contains names of employees. The names may be duplicated, hence I want to extract only the unique names and put them into a data validation dropdown. I don't intent to use VBA and don't want to use any helper columns to drag the formula down to populate the unique names. On pressing F9, the formula should return unique values in an array like this:
{tom;fawad;george;jane;mario;flavia}
The table column looks like this:
List Column 2 Column 3 .....
tom
fawad
george
george
jane
mario
flavia
mario
george
fawad
Right now the formula is returning only one value when pressing F9 key.
=INDEX(list,IFERROR(SMALL(IF(FREQUENCY(MATCH(list,list,0),ROW(INDIRECT("1:"&COUNTA(list)))),ROW(INDIRECT("1:"&COUNTA(list))),""),ROW(INDIRECT("1:"&COUNTA(list)))),""))
I think it may require TRANSPOSE or SUBSTITUTE function to split the returned values across dropdown rows. Someone had demonstrated something like this, but I don't remember the link now.
Anyone know how to create a unique names array formula that I can simply enter directly into a Data Validation dropdown?

Excel Index + if + indirect

I am helping a friend with a work task he's been given and can't figure out the last part. We are given a matrix with a list of workers / users in the following layout:
Location | First Name | Last Name | Property 1 | Property 2 | Property 3 | .. | Property N
Frankfurt | Adam | Schmidt | X | | X | .. | X,
i.e. the properties are in boolean form (X to indicate 'Yes', or empty to indicate 'No').
The task is to search all users based on Location + 1 property that we are able to select from the N properties, i.e. we have a drop-down menu somewhere with all properties 1,2,..,N where we can select exactly 1 of the properties.
The output should be the format: Location | First Name | Last Name.
So, my idea was to replace the standard IF(("array for criteria 1"= "criteria 1") * ("array for criteria 2" = "yes"), ...) with the ADDRESS of the property we select, which we then transformed from text value into cell reference using the INDIRECT function.
To give an example, if we select property 1 (located in column D) in the drop-down menu, the ADDRESS function will return $D$1 as the starting field, and $D$100 as the ending field. These fields are then used inside an INDIRECT function inside the main (long) search function.
I've seen from other posts on the internet that it is possible to use SUM(INDIRECT(cell with starting cell defined&":"&cell with ending cell defined)), so I tried something similar in my function, but it doesn't seem to work.
Here is a picture of the formula & layout of the excel file.
You should organize your sheet into 3 sections:
Data set
Criteria
Result Set
Follow the steps to create the button action for Search.
Navigate to 'Developer' tab.
Click on Insert > Button.
Draw a button. The 'Assign Macro' dialog box will be displayed.
Click on Record.
Enter the macro name as 'SearchRecords' and click on OK.
Click on any empty cell. Navigate to 'Data' tab.
In the 'Sort & Filter' section click on 'Advanced'.
Select 'Copy to another location' radio button and enter the range based on data set and criteria locations.
Click on OK.
Navigate to 'Developer' tab and click on 'Stop Recording'.
Rename the button to 'Search'.
Now you can update the search criteria and click on the search button to update the results in the adjacent location.
A much easier way would be to organize your input data as follows:
This data set is Pivot friendly. You can then create a Pivot Table of the data set. Move the Location and Property fields to the Report Filter section, the Full Name to the Row Labels section and the Location to the Values section.
Please note Full Name is just a concatenated value of 'First Name' & 'Last Name'.

Resources