Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

How to turn Data Value into Field Name (in Formula Tool?)

bccpwc
7 - Meteor

I've searched high and low and haven't found a solution for this hopefully I can explain this. 

 

I have a data set that looks something like this. The Group By column actually gets set earlier in my workflow and it can say either Department, Market or Region. and it will have it for either of the three for all rows. 

 

Emp IDDepartmentMarketRegionGroup By
1HREastGlobalDepartment
2ITEastGlobalDepartment
3HRCentralGlobalDepartment
4LegalCentralGlobalDepartment
5OpsWestUSDepartment
6OpsCentralUSDepartment

 

In this case I want Group By to give me the actual values so that instead of the string "Department" it gives me the actual department for each Employee. 

 

Emp IDDepartmentMarketRegionGroup By
1HREastGlobalHR
2ITEastGlobalIT
3HRCentralGlobalHR
4LegalCentralGlobalLegal
5OpsWestUSOps
6OpsCentralUSOps

 

This is a smaller piece of a bigger workflow but hopefully that makes sense. Thanks for the help in advance.

6 REPLIES 6
bbak
9 - Comet

Could you use a formula tool that has "Group By" as your Output Column and says:

 

IIF([Group By]="Department", [Department],[Group By])

 

This would swap out the actual department name for every instance where the Group By column equals "Department"

 

You could do the same for Market and Region

 

solution.PNG

BenMoss
ACE Emeritus
ACE Emeritus

The complexity here is making it dynamic. 

 

In my instance I isolate the value in the group by field before performing a transpose against the rest of the dataset.

 

By performing a join against the name field and the value in my group by column I can then know the value that needs to be transferred into the 'Group By' column.

Solution attached, and it's dynamic so if 'Department' changes to Market it will cater for this.

 

 solution.png

tyler_sassara
7 - Meteor

You can use the formula tool to make your "Group By" field equal to the "Department" Field. Formula below.

Formula:

[Group by] = [Department]

bbak
9 - Comet

@BenMoss

 

In the original question it only specifies that they wanted to pull the department values. I provided the other two formulas as examples in case there were other instances where values needed pulled over, but the dynamic setup is only needed if this dataset will have different "Group By" values over time and if every instance will require the new values to be pulled over. 

 

Great solution if this is the case, it just depends on whether the added complexity is necessary. 

BenMoss
ACE Emeritus
ACE Emeritus

@bbak my understanding was based on this statement.

 

'Group By column actually gets set earlier in my workflow and it can say either Department, Market or Region. and it will have it for either of the three for all rows. '

 

As you say I may be wrong, but that was just my interpretation :)

bccpwc
7 - Meteor

@BenMoss thank you for the solution, this is in fact what I needed!

 

Your understanding was correct in that it does need to be dynamic, thanks again!

Labels