Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Dynamic Column name

bakaidora
8 - Asteroid

Dear All,

 

I have the following use case.

I have an input file, in this input I have a section somewhere in the file where I can find some values which I would like to use later as column name. I say " somewhere" because it can be anywhere BETWEEN the number (14) after [VARBLE INFO] (they number can be 14, 13 or other number as well - it always depends on how many column names we have) and [HISTORY DATA].

 

Example for 14 parameters:

[VARBLE INFO]

14

Pressure        MPa

Temperature     oC

ShearStress     MPa

ShearRate       1/sec

u-Velocity      cm/sec

v-Velocity      cm/sec

w-Velocity      cm/sec

FlowRate        cc/sec

Density         g/cm3

Conversion      %

Scorch_Index    -

Viscosity       Poise

ViscousHeat     J

ReactiveHeat    J

[HISTORY DATA]

 

Example for 13 parameters:

[VARBLE INFO]

13

Pressure        MPa

Temperature     oC

ShearStress     MPa

ShearRate       1/sec

u-Velocity      cm/sec

v-Velocity      cm/sec

w-Velocity      cm/sec

FlowRate        cc/sec

Density         g/cm3

Conversion      %

Viscosity       Poise

ViscousHeat     J

ReactiveHeat    J

[HISTORY DATA]

 

It can happen that next time I will have 15 parameters which I need to use later as column name.

 

Currently, I have 2 workflows 1 workflow for 13 parameters and an other workflow for 14 parameters but I would like to make this more dynamic.

Currently, in the workflow with 13 parameters I rename the columns manually with the Select tool.

bakaidora_0-1665835080566.png

 

As I feel, I need to solve 2 issue:

1. Get the needed column names from the tool --> after the number after [VARBLE INFO] and before [HISTORY DATA].

2. Use this columns names in the Renaming of the Columns dynamically.

 

Could you please help me, how can I solve this?

Thanks, Dóra

6 REPLIES 6
Felipe_Ribeir0
16 - Nebula

Hi @bakaidora 

 

One way of doing this is using the dynamic rename tool with the proper configuration. Take a look at the attached example, i think you can adapt it to your situation.

 

 

1)Original Headers

Felipe_Ribeir0_2-1665835835886.png

2)List of correct headers (must be ordered by the same sequence than 1)

 

Felipe_Ribeir0_4-1665835891285.png

3)After the dynamic rename

 

Felipe_Ribeir0_5-1665835923172.png

 

 

 

hellyars
13 - Pulsar

@bakaidora 

 

Sample data would be helpful.  For example, I don't know how your incoming fields will be labeled.

 

Nonetheless, I took a stab it.  It's not elegant but it works.

 

I created a list of field names for 13 and 14 field incoming scenarios. 

The workflow counts the number of incoming fields and matches the total to the appropriate scenario and renames the fields.

 

I left it off, but I was also playing with a way to dynamically change the field type using dynamic select and multi-field tools.

 

 

 

 

hellyars_0-1665862701130.png

 

danilang
19 - Altair
19 - Altair

Hi @bakaidora 

 

Here's a dynamic solution that will adapt to any number of columns

 

danilang_1-1665919239346.png

On the bottom path, the Muilt-Row tools flags the rows from the header file that we want to keep.  the others are removed by the filter tool.  The Formula tools adds the brackets around the units and the rows are sequentially number by the Record ID tool.  The Dynamic Rename uses positional rename to rename the columns in the data file.

danilang_3-1665919656230.png

 

This will work for any number of columns as long as the data file matches the header file.  I've include a sample with 13 columns as well for you to try. 

 

Dan  

bakaidora
8 - Asteroid

Dear @danilang

 

this is almost what I expect, but unfortunately, I have "\d+" after the [SENSOR INFO], as well.

Currently, the workflow is setting '1' on the Keep from row nr. 8.

 

bakaidora_0-1666784622544.png

bakaidora_1-1666784826127.png

Thanks so much for helping.

Dóra

 

bakaidora
8 - Asteroid

dear @hellyars,

 

I am not able to check your solution  because of my Alteryx version.

"This workflow was created by a more recent version of Alteryx, and may contain tools or functionality not present in this version. Alteryx does not support using an earlier version of Alteryx to open a workflow created with a newer version. For best results, download the latest version of Alteryx."

Unfortunately, this newer version is not available at my company.

 

Thanks,

Dóra

bakaidora
8 - Asteroid

Dear @Felipe_Ribeir0 ,

 

the solution what you mentioned is good if the cells what I am searching for are in a fixed place and the number is fixed as well.

But as I mentioned it is changing. Sometimes it starting in row 14 sometimes in row 15 and so on.

And sometimes I have 12 values which I need to use later as a column but in other case this is 13, in a third case this is 14.

 

Thanks, Dóra

Labels
Top Solution Authors