How to sort by latest date in SUMPRODUCT

lost_in_the_sauce

Board Regular
Joined
Jan 18, 2021
Messages
128
Office Version
  1. 365
Platform
  1. Windows
I have an array of sales data from multiple stores (180), and the data is entered by the stores at the end of each month. It all goes into an array. However, some stores will update their numbers, and in the array it adds a new line with a date/timestamp. For example, New York has 4 entries for February 2022, with different timestamps, and I only want the last one.

Currently I am using SUMPRODUCT like this:

=SUMPRODUCT((Data!$B$2:$B$1214=$B18)*(Data!$J$1:$P$1=C$2)*(Data!$F$2:$F$1214=$A18)*(Data!$J$2:$P$1214))

where $B18 is the month, C$2 is the $ category (sales, rent, etc), $A18 is the location, and $J:$2:$P$14 is the array of number values.

I have a column G with the timestamp. I've tried MAX but it looks like it pulls everything, I just want to add the condition for the latest date that also matches the other 3 conditions.
 
oh.. you want to pick the maximum date for each month when you're adding everything together?

I guess you need to explain what your sumproduct is selecting regarding Column G. Or is this an add to that formula? I don't see an caparisons with G in your SUMPRODUCT formula.
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
are the values in J1 to P1 fiscal month names/ids? I'm confused with the relations ship between B18 being February and the fiscal month being P01(Jan) - not necessarly because they are different months but in different rows in your matrix? Or is there a divider where one side is a data matrix column J-P and the other side A-I is some kind of time line? I'm really confused.
 
Upvote 0
I think if you insert this array calc into the sumproduct formula it may work: I can't test it because I don't have the same data as you. But I think column and cell references are close (not sure about rows). i'm also not sure if my parens are correct. I cut from the above.
Excel Formula:
(--(MAX((--(B14=$B$2:$B$11))*($G$2:$G$11))=$G$2:$G$11))
 
Upvote 0
I think if you insert this array calc into the sumproduct formula it may work: I can't test it because I don't have the same data as you. But I think column and cell references are close (not sure about rows). i'm also not sure if my parens are correct. I cut from the above.
Excel Formula:
(--(MAX((--(B14=$B$2:$B$11))*($G$2:$G$11))=$G$2:$G$11))
I didn't even see the second page of comments.

The formula from post 8 works but isn't differentiating by store, just the max timestamp across all entries.

>I guess you need to explain what your sumproduct is selecting regarding Column G. Or is this an add to that formula? I don't see an caparisons with G in your SUMPRODUCT formula.

Column G is the timestamp. The existing SUMPRODUCT doesn't have this because up until now we have been cleaning the data to remove all entries that weren't the most recent, I'm just trying to make it quicker going forward so that we can just paste the full dataset and not have to clean it up each time.

>are the values in J1 to P1 fiscal month names/ids? I'm confused with the relations ship between B18 being February and the fiscal month being P01(Jan) - not necessarly because they are different months but in different rows in your matrix? Or is there a divider where one side is a data matrix column J-P and the other side A-I is some kind of time line? I'm really confused.

J-P are the columns/is the array with all of the financial data, Revenue, Payroll, Rent, etc. I'm not great with SUMPRODUCT so it's what I found on the web that worked.

>I think if you insert this array calc into the sumproduct formula it may work: I can't test it because I don't have the same data as you. But I think column and cell references are close (not sure about rows). i'm also not sure if my parens are correct. I cut from the above.

I'll try this.

Also, here is an example of my output and data
 

Attachments

  • data.JPG
    data.JPG
    141.8 KB · Views: 3
  • output.JPG
    output.JPG
    113.6 KB · Views: 5
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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