About EasyMorph Tutorials & Examples Web-help

Parameterize column / dynamic column from string


#1

Is it possible to pass a column name as a parameter? I have a fairly complicated subroutine that I’d like to use the Call Project transformation on. The source dataset won’t always have the same column names - although as a workaround I could add calculated columns to fit a certain schema. It would be useful I think to be able to eval a string and have it resolve to a column name.


#2

It’s not possible yet. In version 3.6 we will have a transformation that selects only columns which names exist in another table. It will provide a bit of flexibility for column schemes.

Sometimes it makes sense to unpivot the table first, especially when the table is a matrix. In this case its columns become rows which makes data transformation more convenient. Later the result can be pivoted back, if needed.


#3

Agree this would be useful. I am running into this issue now. I am consuming data from arbitrary Excel files, and would like to set some parameters for important column names (for instance, what the name of the key column is so I can match it against a reference table).


#4

@jdavidhobbs,

take a look at the “Rename by lookup” transformation. You can use it to rename a column which name is specified by a parameter, to some generic name. Then do the matching.


#5

The parameterization of a column - is this still not available? If it is - I need guidance :smile: - if not, is it included in future planned releases?


#6

“Rename by lookup” can be used to work with columns which name is specified using a parameter.

It may be necessary to rename the column to a generic name if additional actions required. See the example below:
parameterized-column-name.morph (4.3 KB)


#7

Hi - Of course :slight_smile:

What I meant to go after was use a column as calculated parameter in same project. That’s another thing, which I can’t seem to solve.


#8

Not sure I understand your question. Can you provide an example?


#9

I can try…

I have a project to process invoice specifications for partners. The output files will have to be uploaded to partner specific folders on an FTP server.

When using the File Transfer action, I only have the options to give a specific filename, or to use a parameter - both for local and remote files…
image

As the output location is partner specific, I would like to calculate the location in a ‘Outputfolder’ column, and use that column as definition for the folders in the action.

When creating parameters, it’s only possible to calculate a string using other parameters, not columns in a table within the project, as it is calculating a new column in a given table.


What I have done now, and this is probably the right way, is have another project iterate the file processing project, passing the calculated folders as parameters, to use in the file transfer action.

I can see the issue in the project parameters, to calculate based on a column when no related table is given (normally when calculating a new column within a table, available columns are table specific) - But I guess an extension to the expression builder, could then be to first select a source table within the project, then select a column within that table… Thinking about it, this could sound like something that may be possible in the new ‘module’ feature in the coming major release?


#10

There is a conceptual ambiguity here. A parameter is a single value (i.e. scalar) and a column in general case is many values (i.e. vector). If a parameter is calculated based on a column with 10 values, which of these 10 values should be used to calculate the parameter?

Parameters by design are global for a project (module, starting from ver.4), not local to a table or column.

If a parameter needs to be calculated based on a column, the right way to do it is to have a separate project (or module, starting from ver.4) and use the “Iterate” action to assign a calculated value from a column to a parameter of that separate project.