本帖最后由 alan57 于 2023-9-21 09:40 编辑
多层级/未知层级 BOM缺料计算 交流:https://club.excelhome.net/forum ... 1333811&_dsign=
- =LET(_a1,H3:H34,_b1,I3:J34,_c2,UNIQUE(FILTER(_a1,COUNTIF(_b1,_a1)=0)),_d1,IFNA(DROP(REDUCE(_c2,_a1,LAMBDA(x,y,DROP(REDUCE(0,SEQUENCE(ROWS(x)),LAMBDA(m,n,LET(_e,INDEX(x,n,),_f,TAKE(_e,,-2),_g,FILTER(_b1,_a1=@+_f,""),_h,HSTACK(_e,@+_f,_g),VSTACK(m,IF(COUNTIF(_a1,@+_f),IFNA(_h,TAKE(_h,1)),_e))))),1))),,1),""),REDUCE(P2:S2,SEQUENCE(ROWS(_d1)),LAMBDA(m,n,VSTACK(m,LET(_a,B2:F2,_c1,INDEX(_d1,n,),_b,INDEX(B3:F5,XMATCH(@_c1,A3:A5),),_c,TOROW(IF(_c1="",\,_c1),3),_e,TRANSPOSE(FILTER(VSTACK(_b,_a),_b<>0)),xl,LAMBDA(m,XLOOKUP(m,L3:L25,M3:M25,0)),_d,VSTACK(HSTACK(@_c,@_c,1),WRAPROWS(_c,3)),_f2,TAKE(_d,,-1),_f4,TAKE(xl(TAKE(_d,,-2)),,1),_f3,IF(AND(_f4=0),0,_f4),_f,TAKE(_d,,-1)&","&_f3,_f1,TOCOL(TAKE(DROP(REDUCE(0,TAKE(_e,,1),LAMBDA(x,y,HSTACK(x,SCAN(y,TAKE(_d,,-1),LAMBDA(x,y,x*y))))),,1),-1)),_i,TAKE(SCAN(0,VSTACK(DROP(_f2,1),1)&","&_f3,LAMBDA(x,y,(x+TEXTAFTER(y,","))*TEXTBEFORE(y,","))),-1),_o1,TAKE(REDUCE(-_i,_f1,LAMBDA(x,y,VSTACK(x,IF(@TAKE(x,-1)<0,y+x,y)))),-ROWS(_f1)),_o2,--XLOOKUP(@_c&@TAKE(_c,,-2),CHOOSECOLS(m,2)&TAKE(m,,1),TAKE(DROP(m,,2),,1),0),_o3,IF(_o2,_f1,_o1),_o,IF(_o3<0,0,_o3)&","&TEXT(TAKE(_e,,-1),"yyyy/mm/dd"),_j,HSTACK(@TAKE(_c,,-2),@_c),_k,IFNA(HSTACK(_j,DROP(REDUCE(0,_o,LAMBDA(x,y,VSTACK(x,TEXTSPLIT(y,",")))),1)),_j),_k)))))
复制代码 这个太难了,一千多的长火车,解出来感觉与大神有些数据还是有差异,不知道对不对。
|