We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Dynamically Changing column Header Based on ANother Column Value

tjanwe
5 - Atom

Hi!

 

Might be a stupid question but I would like to change the column header "MetricValue" to the data in "%WeeksBreached" column. The data in "%WeeksBreached" column will all be the same throughout the columns, as it is appended. However, the number can be different eg 0.2 or 0.3 or 0.4. Please see sample input and expected output below:

 

Input

KRIMetricValue
%WeeksBreached
abc30.2
def60.2
ghi20.2

 

Please see below output, where the 20% comes from the 0.2 in "%WeeksBreached" column.

Output

KRI20%WeeksBreachValue
%WeeksBreached
abc30.2
def60.2
ghi20.2
2 REPLIES 2
abacon
12 - Quasar

@tjanwe I would do the following -

  • Start by adding a recordID tool
  • Then using a transpose tool selecting the RecordID field as the key column and the rest of the columns as the data columns.
  • Next you will want a formula tool and create a field called "New Headers" with a formula like this - if contains([Name],"%WeeksBreached") then tostring([Value]*100) + [Name] else "" endif.
  • Now you will use a multi-row formula tool that updates the [Name] with this formula - if contains([Name],"MetricValue") then [Row+1:New Headers"] else [Name] endif.
  • Last piece will be a Cross Tab tool grouped on the Record ID with the [Name] field as the column headings and the [Value] field as the values.

This should get you what you need.

If this works for you, please mark it as the solution so others may find it quicker.

 

 

tjanwe
5 - Atom

Thank you!

 

Labels
Top Solution Authors