将企业微信同步过来的多个部门拆分到不同的字段中,根据部门id对应过来,再拼接,
具体公式如下:
部门1
IF(MFISNULL(FIND(",",$MF(部门id)$)),$MF(部门id)$,LEFT(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),FIND(",",SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""))-1))
部门2
IF(MFISNULL(FIND(",",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$,"",1),",","",1))),SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$,"",1),",","",1),LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$,"",1),",","",1),FIND(",",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$,"",1),",","",1))-1))
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$,"",1),",","",1)
部门3
IF(MFISNULL($MF(部门2)$),"",IF(MFISNULL(FIND(",",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$,"",1),",","",1))),SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$,"",1),",","",1),LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$,"",1),",","",1),FIND(",",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$,"",1),",","",1))-1)))
部门4
IF(MFISNULL(FIND(",",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$&","&$MF(部门3)$,"",1),",","",1))),SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$&","&$MF(部门3)$,"",1),",","",1),LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$&","&$MF(部门3)$,"",1),",","",1),FIND(",",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$&","&$MF(部门3)$,"",1),",","",1))-1))
部门5
IF(MFISNULL($MF(部门3)$),"",IF(MFISNULL(FIND(",",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$&","&$MF(部门3)$&","&$MF(部门4)$,"",1),",","",1))),SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$&","&$MF(部门3)$&","&$MF(部门4)$,"",1),",","",1),LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$&","&$MF(部门3)$&","&$MF(部门4)$,"",1),",","",1),FIND(",",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($MF(部门id)$,"[",""),"]",""),$MF(部门1)$&","&$MF(部门2)$&","&$MF(部门3)$&","&$MF(部门4)$,"",1),",","",1))-1)))
组合
MFE(1,MFVLOOKUPC("企业部门","部门名称","部门id",$MF(部门1)$))&IF(MFISNULL($MF(部门2)$),"",","&MFE(1,MFVLOOKUPC("企业部门","部门名称","部门id",$MF(部门2)$)))&IF(MFISNULL($MF(部门3)$),"",","&MFE(1,MFVLOOKUPC("企业部门","部门名称","部门id",$MF(部门3)$)))&IF(MFISNULL($MF(部门4)$),"",","&MFE(1,MFVLOOKUPC("企业部门","部门名称","部门id",$MF(部门4)$)))&IF(MFISNULL($MF(部门5)$),"",","&MFE(1,MFVLOOKUPC("企业部门","部门名称","部门id",$MF(部门5)$))) |