In relation to my last question at How can I fix this Excel LAMBDA formula to result all SKUs and prices, type of Unpivot formula
@Ike created this LAMBDA
which worked perfectly for the 3 columns of normal price data, now the next step I have to figure out is adding 3 more columns of Net prices, a Unit to divide, and a bit more info per row, I've listed a few examples below.
Here's the source table data, FLC is the normal Case cost, the Discount is subtracted by this to create the NETC. The UNITC, UNITP, and UNITU are the units which the cost would be divided by in order to create the NETC (except the 0's, where I replace the #DIV/0
error with a 0 value)
SKU | DESC | DISCOUNT | UNITC | UNITP | UNITU | FLC | FLP | FLU | NETC | NETP | NETU |
---|---|---|---|---|---|---|---|---|---|---|---|
99999 | Bottle | 5 | 1 | 0 | 5 | 100 | 0 | 20 | 95 | 0 | 19 |
12345 | Case Pack | 0 | 1 | 2 | 24 | 48 | 24 | 2 | 48 | 24 | 2 |
67890 | Unit | 2 | 0 | 0 | 1 | 0 | 0 | 50 | 0 | 0 | 48 |
This is what the data would ideally look like when complete:
SKU | Description | UNIT | FL | DISCOUNT | NET |
---|---|---|---|---|---|
99999 | Bottle | 1 | 100 | 5 | 95 |
99999 | Bottle | 0 | 0 | 5 | 0 |
99999 | Bottle | 5 | 20 | 5 | 19 |
12345 | Case Pack | 1 | 48 | 0 | 48 |
12345 | Case Pack | 2 | 24 | 0 | 24 |
12345 | Case Pack | 24 | 2 | 0 | 2 |
67890 | Unit | 0 | 0 | 2 | 0 |
67890 | Unit | 0 | 0 | 2 | 0 |
67890 | Unit | 1 | 50 | 2 | 48 |
And finally, here are the current results / current LAMBDA
:
SKU | FL |
---|---|
99999 | 95 |
99999 | 0 |
99999 | 19 |
12345 | 48 |
12345 | 24 |
12345 | 2 |
67890 | 0 |
67890 | 0 |
67890 | 48 |
=LAMBDA(SKU_col,FL_cols,
LET(SCT,COUNTA(SKU_col)-1,
SKU,INDEX(SKU_col,2,1):INDEX(SKU_col,SCT+1,1),
FL,INDEX(FL_cols,2,0):INDEX(FL_cols,SCT+1,0),
s,MAKEARRAY(ROWS(SKU),COLUMNS(FL)*2,
LAMBDA(r,c,IF(ISODD(c),INDEX(SKU,r),INDEX(FL,r,c/2)))),
WRAPROWS(TOCOL(s),2)))
(Currently, this LAMBDA
is only referencing the column for SKU, and the columns for FLC,FLP,FLU)
A bit different from the first solution:
=LET(SKU,A2:B4,
Discount,C2:C4,
Unit,D2:F4,
FL,G2:I4,
Net, J2:L4,
cnt,ROWS(SKU),
SKUs,INDEX(SKU,ROUNDUP(SEQUENCE(cnt*3)/3,0),{1,2}),
Discounts,INDEX(Discount,ROUNDUP(SEQUENCE(cnt*3)/3,0)),
data,HSTACK(SKUs,TOCOL(Unit),TOCOL(FL),Discounts,TOCOL(Net)),
header,{"SKU","Description","UNIT","FL","DISCOUNT","NET"},
VSTACK(header,data))