Table: create array of rows containing values

tdcockers

New Member
Joined
Mar 29, 2016
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi all... I'm trying to build a crop plan (which crop is in which field, on a month to month basis) and then use that for calculating total area planted with different crops at any time.

Table looks like this:
Capture.PNG


I've been unable to figure out a formula that will essentially create an index of whether a value appears anywhere in a row that I can use to multiply by the area. For instance, if the lookup value was 'Chickpea 24/25' then the array would be {0, 1, 1, 0, 0, 0, 0, 0, 0, 1} that could then be multiplied with the Area column, to give a total area of 765. Any tips?

Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Perhaps the below will help, I have made a few assumptions:
Book1
ABCDEFGHI
1Field PlanAreaDec-23Jan-24Feb-24Lookup List
2G1192BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
3G2340CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25
4G5240CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25Dave
5L174DaveBARLEY 23/24BARLEY 23/24
6L2254BARLEY 23/24BARLEY 23/24BARLEY 23/24
7L3162BARLEY 23/24BARLEY 23/24BARLEY 23/24
8R1343BARLEY 23/24DaveBARLEY 23/24
9R2330BARLEY 23/24BARLEY 23/24BARLEY 23/24
10R3125BARLEY 23/24BARLEY 23/24Dave
11R4185CHICKPEA 24/25DaveCHICKPEA 24/25
12Total2245
13
14CHICKPEA 24/25765580765
15
Sheet1
Cell Formulas
RangeFormula
I2:I4I2=UNIQUE(TOCOL(Table1[[Dec-23]:[Feb-24]]))
B12B12=SUBTOTAL(109,[Area])
C14C14=SUMIF(Table1[Dec-23],$A$14,INDIRECT("Table1[Area]"))
D14D14=SUMIF(Table1[Jan-24],$A$14,INDIRECT("Table1[Area]"))
E14E14=SUMIF(Table1[Feb-24],$A$14,INDIRECT("Table1[Area]"))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
A14List=I2#
 
Upvote 0
Thanks. Not quite the outcome I was looking for, let me try to explain better. I'm possibly just making it unnecessarily difficult, but that's how we learn, right?

There is already a lookup list of all possible crops, which is also used as validation for the cells in the crop plan so values will always be exact matches. What I'm trying to do is write a formula that detemines if a field is used at any time by each crop in the plan, and put that in a column next to the lookup. So in your spreadsheet, cells J2:J4 would have 1480, 765 and 727 in them.

It's simple enough to do with a helper table/cells, but I'm trying to do it with a formula that is robust enough to deal with changes in the size of the crop plan both horizontally (adding future years while keeping historical ones) and vertically (adding fields).
 
Upvote 0
Are you looking to sum only the last column in the table, as below:
Book1
ABCDEFGHIJ
1Field PlanAreaDec-23Jan-24Feb-24Mar-24CropArea
2G1192BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/241480
3G2340CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25765
4G5240CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25
5L174BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
6L2254BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
7L3162BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
8R1343BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
9R2330BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
10R3125BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
11R4185CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25
Sheet1
Cell Formulas
RangeFormula
J2:J3J2=SUMIF(TAKE(Table1,,-1),I2:I3,Table1[Area])
Dynamic array formulas.
 
Upvote 0
Are you looking to sum only the last column in the table, as below:
Book1
ABCDEFGHIJ
1Field PlanAreaDec-23Jan-24Feb-24Mar-24CropArea
2G1192BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/241480
3G2340CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25765
4G5240CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25
5L174BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
6L2254BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
7L3162BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
8R1343BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
9R2330BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
10R3125BARLEY 23/24BARLEY 23/24BARLEY 23/24BARLEY 23/24
11R4185CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25CHICKPEA 24/25
Sheet1
Cell Formulas
RangeFormula
J2:J3J2=SUMIF(TAKE(Table1,,-1),I2:I3,Table1[Area])
Dynamic array formulas.

It would be much easier to carry out any analyis if the data was structured so that each row represented the use in a field for a particular month.
This is a standard way of organisng such data.

This structure would then easily facilitate the adding of months, fields and crops.

The date column holds the first day of the month.

If put in a table, the formula would not need to be changed if another month is added.

Are you able to do this?

create array of rows containing values.xlsm
ABCD
1Field PlanAreaDateCrop
2G1192Dec 23BARLEY 23/24
3G2340Dec 23CHICKPEA 24/25
4G5240Dec 23CHICKPEA 24/25
5L174Dec 23Dave
6L2254Dec 23BARLEY 23/24
7L3162Dec 23BARLEY 23/24
8R1343Dec 23BARLEY 23/24
9R2330Dec 23BARLEY 23/24
10R3125Dec 23BARLEY 23/24
11R4185Dec 23CHICKPEA 24/25
12G1192Jan 24BARLEY 23/24
13G2340Jan 24CHICKPEA 24/25
14G5240Jan 24CHICKPEA 24/25
15L174Jan 24BARLEY 23/24
16L2254Jan 24BARLEY 23/24
17L3162Jan 24BARLEY 23/24
18R1343Jan 24Dave
19R2330Jan 24BARLEY 23/24
20R3125Jan 24BARLEY 23/24
21R4185Jan 24Dave
22G1192Feb 24BARLEY 23/24
23G2340Feb 24CHICKPEA 24/25
24G5240Feb 24CHICKPEA 24/25
25L174Feb 24BARLEY 23/24
26L2254Feb 24BARLEY 23/24
27L3162Feb 24BARLEY 23/24
28R1343Feb 24BARLEY 23/24
29R2330Feb 24BARLEY 23/24
30R3125Feb 24Dave
31R4185Feb 24CHICKPEA 24/25
Sheet1
 
Upvote 0
Solution
Are you looking to sum only the last column in the table, as below:
Not quite, I'm trying to sum the area column when the crop appears anywhere in the table to the right of it. As Herakles suggested, an unpivoted version of the table would be simpler for analysis; but for a visual of what is in the ground when, and when it changes, the table is a much easier to parse view.

Having said all that, I that between you I have my solution... unpivot into dynamic array, then calculate areas. Thanks!
 
Upvote 0
Perhaps you could create the answers manually and show us what you want it to look like?
 
Upvote 0
Thanks, I've solved this unpivoting the crosstab, then runnning the calculations against that. Always happy to hear improvements/suggestions of course. Columns A through E will be hidden in the working version.

20230927_FY23 Budget Prelim v2.xlsx
ABCDEFGHIJKLMNO
3 Crops Field Plan Jun 2023
4Lookup Name CodeAreaFieldAreaJul 2023Aug 2023Sep 2023Oct 2023
5G145108BARLEY 23/24BARLEY 23/24 BARLEY 23/24 10686 G1 192.00 BARLEY 23/24 BARLEY 23/24 WHEAT 23/24 WHEAT 23/24
6G145139BARLEY 23/24BARLEY 24/25 BARLEY 24/25 110 G2 340.00 FALLOW SORGHUM 23/24 SORGHUM 23/24 CHICKPEA 23/24
7G145170WHEAT 23/24WHEAT 23/24 WHEAT 23/24 20446 G5 240.00 FALLOW BARLEY 23/24 SORGHUM 23/24 SORGHUM 23/24
8G145200WHEAT 23/24WHEAT 24/25 WHEAT 24/25 210 L1 74.00 CHICKPEA 23/24 CHICKPEA 23/24 CHICKPEA 23/24 CHICKPEA 23/24
9G245108FALLOWSORGHUM 23/24 SORGHUM 23/24 30580 L2 254.00 FALLOW WHEAT 23/24 WHEAT 23/24 BARLEY 23/24
10G245139SORGHUM 23/24SORGHUM 24/25 SORGHUM 24/25 310 L3 162.00
11G245170SORGHUM 23/24CHICKPEA 23/24 CHICKPEA 23/24 40414 R1 343.00
12G245200CHICKPEA 23/24CHICKPEA 24/25 CHICKPEA 24/25 410 R2 330.00
13G545108FALLOWFALLOW FALLOW 90834 R3 125.00
14G545139BARLEY 23/24GENERAL/OVERHEAD GENERAL/OVERHEAD 990 R4 185.00
15G545170SORGHUM 23/24Total2,245.00
16G545200SORGHUM 23/24
17L145108CHICKPEA 23/24
18L145139CHICKPEA 23/24 Rotation Summary
19L145170CHICKPEA 23/24Field12345
20L145200CHICKPEA 23/24 G1 BARLEY 23/24 WHEAT 23/24
21L245108FALLOW G2 FALLOW SORGHUM 23/24 CHICKPEA 23/24  
22L245139WHEAT 23/24 G5 FALLOW BARLEY 23/24 SORGHUM 23/24  
23L245170WHEAT 23/24 L1 CHICKPEA 23/24    
24L245200BARLEY 23/24 L2 FALLOW WHEAT 23/24 BARLEY 23/24  
25L345108 L3    
26L345139 R1    
27L345170 R2    
28L345200 R3    
29R145108 R4    
Field Plan
Cell Formulas
RangeFormula
L4:O4L4=EDATE(L3,SEQUENCE(1,COLUMNS(tblFields)-2))
A5:C44A5=TEXTSPLIT(TEXTJOIN("^",FALSE,TOCOL(tblFields[Field Plan]&"|"&L4#&"|"&DROP(tblFields,0,2))),"|","^")
E5:E14E5=tblCrops[Name]
H5:H14H5=SUM(SUMIF(tblFields[Field Plan],UNIQUE(CHOOSECOLS(FILTER($A$5#,CHOOSECOLS($A$5#,3)=[@Name]),1)),tblFields[Area]))
K15K15=SUBTOTAL(109,[Area])
K19:O19K19=SEQUENCE(1,COLUMNS(tblRotations)-1)
K20:O29K20=IFERROR(INDEX(TRANSPOSE(UNIQUE(CHOOSECOLS(FILTER($A$5#,CHOOSECOLS($A$5#,1)=[@Column1]),3))),1,K$19),"")
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F:DWExpression=SEARCH("FALLOW",F1)=1textNO
F:DWExpression=SEARCH("BARLEY",F1)=1textNO
F:DWExpression=SEARCH("WHEAT",F1)=1textNO
F:DWExpression=SEARCH("SORGHUM",F1)=1textNO
F:DWExpression=SEARCH("CHICKPEA",F1)=1textNO
4:4Expression=A4<>""textNO
Cells with Data Validation
CellAllowCriteria
L5:O14List=$E$5#
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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