TEXTJOIN criteria that are summed based on uniqueness

lampshade22

New Member
Joined
Aug 24, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all

I am trying to achieve a summary of some data using the TEXTJOIN function.
The output depends on which Order No. the product has been allocated to. I would like to combine all the weights of each product in the output, regardless of whether they are Forecast Yield or Actual Yield. If the order allocation has any forecasted yields in it, I want to denote this with an asterisk. I have tried but I can't work out how to sum up the weights by product.

My desired output is highlighted in yellow.

The formula in C3 is:
Excel Formula:
=TEXTJOIN(CHAR(10),TRUE,IFS($E$8:$E$25<>B3,"",($E$8:$E$25=B3)*($C$8:$C$25<>""),$B$8:$B$25&" x "&ROUND($C$8:$C$25,1)&"Kg *",($E$8:$E$25=B3)*($D$8:$D$25<>""),$B$8:$B$25&" x "&ROUND($D$8:$D$25,1)&"Kg"))
[/CODE]

I hope that makes sense. Any help would be greatly appreciated!

Thanks

Screenshot 2024-08-24 125104.png
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
The following is based on the assumption that there is always either "Forecast" or "Actual" filled (but never both):

Excel Formula:
=LET(
p,$B$8:$B$25,
s_1,$C$8:$C$25,
s_2,$D$8:$D$25,
s,--(s_1&s_2),
o,$E$8:$E$25,
a,--(NOT(ISBLANK(s_1))),
f,FILTER(HSTACK(p,s,o,a),o=B3),
u,UNIQUE(CHOOSECOLS(f,1)),
t,DROP(REDUCE("",u,LAMBDA(x,y,VSTACK(x,ROUND(SUM(FILTER(CHOOSECOLS(f,2),CHOOSECOLS(f,1)=y)),1)))),1),
y,DROP(REDUCE("",u,LAMBDA(x,y,VSTACK(x,SUM(FILTER(CHOOSECOLS(f,4),CHOOSECOLS(f,1)=y))))),1)>0,
TEXTJOIN(CHAR(10),,u&" x "&t& " kg"&IF(y=TRUE," *","")))
 
Upvote 0
Wow, thank you.
One last thing, how can I prevent it from displaying a CALC error if the array is empty?
 
Upvote 0
Hello, just wrap the last part starting with TEXTJOIN into IFERROR function...
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top