目标:用Alteryx创建一个map id的workflow

背景需求:从一个数据库导出具有parent-child关系的两张表,child表上的record通过id字段关联parent表上的record;将该两张表导入到另一个数据库时,先导入parent表,因为parent表的id字段发生了变化,child表上用于做mapping的id需要全部替换成新数据库中对应parent的id. 该workflow读入source parent, source child和target parent三个文件,预先定义好parent表上除了id字段以外的其他可唯一标识一条parent record的一到多个字段,通过该组合字段找到target parent和source parent的mapping关系;再通过已知的source child和source parent的mapping关系,将source child map target parent, 生成target child文件,导入新数据库。

 

过程中所用到的tools:

1. Input Data 每个数据文件分别创建一个Input Data, 填写文件路径

2. Join 可用于实现类似Excel vlookup功能,首先将source parent和target parent作为输入, 通过唯一标识的组合字段关联,生成source parent id与target parent id mapping; 以该mapping作为输入,与source child通过id字段关联,生成child与target parent id mapping. Unselect old id, select new id.

3. Select 用于rename new id字段的title成old id字段的title.

4. Output Data 输出target child文件

保存该workflow之后,如果需要替换输入文件,有如下操作:

更改文件路径为新文件;按F5刷新workflow, 此时Join里面会刷新fileds, 之前不存在的会增加进来,之前存在的会变成黄色,表示missing, 选择‘Options>Forget All Missing Fields’, 可清除所有不存在的字段。后续需更新关联字段,重新run workflow.

 

保存成.yxzp格式的包:

Options->Export Workflow->Set 'Package Location', select input/output files->Save.

该包可移植到其他环境,在其他装了Alteryx的机器上双击->import即可使用。

 

有用的tips:

Alteryx里面的tools非常多,刚开始使用时没有方向该如何划分步骤,并使用哪一个tool可实现步骤的功能。可在右上角的搜索栏里面尝试用关键词进行搜索,搜索的结果里面除了出现匹配的tool之外还会匹配到Alteryx community里面的话题,进入community搜索更多可能能找到实现方法。