我的表格如下:
ID IsCreated ParentID
101 0 NA
102 1 101
103 0 NA
104 1 102
105 1 104
我想添加一个名为“OGParentID”的新列,其结果如下所示:
ID IsCreated ParentID OGParentID
101 0 NA 101
102 1 101 101
103 0 NA 103
104 1 102 101
105 1 104 101
这里使用的逻辑如下: 对于每一行,检查IsCreated=1,如果是,则在ID列中查找ParentID以检查IsCreated是否为0,如果是,则将OGParentID设置为已查找的父ID,否则,检查已查找的ParentID的父ID并继续循环
你可以做:
您可以编写一个函数,然后将其应用于列
此代码将获取每个ParentID并将其提供给函数
lookup
函数
lookup
根据OP的要求执行以下操作:相关问题 更多 >
编程相关推荐