Selecting specific columns in LINQ
To get going, open Data Search → Explore Your Data and click on the Free Text Query option. Here you can build your query using LINQ.
To simplify your query execution, Devo allows you to run a query with a shortcut when using your keyboard: CTRL+Enter for PC users and CMD+Enter for Mac users. Hover your mouse over the Run button to see the shortcut.
In this example the data table is demo.ecommerce.dataÂ
and you only want the eventdate
and method
columns.
Enter fromÂ
and the table name, followed by select
and the columns you want to appear. If needed, remember that you may add a new name to the column using the operator as
. If you don't know the column names, or the table has a large number of columns, click on the Show Table Fields button and the list of columns will appear on the right.
Use the filter to search for the names of the columns if you cannot see them at a glance. Clicking on the headings Name and Type will organize them into their respective alphabetical order.
Alternatively, you can give new names to the columns using the operator as
. The columns will only appear in the search window under their new names:
from table
select column1 as name
select column2 as name
Uncheck the Select All Fields option in the bottom right of the query if you only want to show the selected columns. This option is activated by default and will display all of the table's columns in the search window, regardless of the columns you select to display.
Below you can see that—having unchecked Select All Fields—only the selected columns are displayed, which in this case are eventdate
, domain
, action
and sessionid
.
Once the table is open, you can still modify the query to include tables you did not include earlier or exclude them in case you do not need them. All you need to do is open the Query code editor and use the syntax explained above. As in the Free Text Query, you can click on the Show Table Fields button to see all of the available columns in the data table.
Selecting only the required columns differs from running a query with a data table and later hiding columns. Using this method, you can only hide and display the columns that you have selected when running the initial query. Take a look below to see how this works.
Using the same logic, if you return to the table in the applied query operations bar you will notice that none of the columns from the original table will be displayed. This is because your original LINQ query specified that only certain information be shown.
Operations using the Free Text Query
Devo allows you to run operations directly from the Free Text Query, with the process functioning just like selecting specific columns in LINQ as detailed above.
from table
select operation (column)
You can run multiple operations at once but the data returned cannot be used for further operations, such as alerts, etc.
Duplicating columns
Leaving the Select All Fields option activated while simultaneously selecting specific columns will result in all of the table's columns being displayed, with the selected ones being duplicated at the end of the other columns. This function can be useful if you wish to duplicate the information contained in a certain column and display it under a different name. In that case, you can enter the following free text query:
from table
select column1 as name
select column2 as name
The original columns will still be displayed but the duplicates, under their new names, will appear near the very end of the query. In this example, we again use the table demo.ecommerce.data
and want to rename the eventdate
column as when and the method
column as how. We leave Select All Fields activated.