Formula - Sumif(s)? Sumproduct? etc.

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,644
Office Version
  1. 365
Platform
  1. Windows
I am looking for a formula to produce the results in column P.

XCash Summary.xlsm
FGHIJKLMNOPQ
1
28 Apr 25HKD1.0000108,099
315 Oct 24USD1.00006,407
420 Jan 25CNY1.0000535
514 Oct 24HKD1.000031,571
610 Mar 25HKD35,901
79 Dec 24HKD1.000042,575
827 Feb 25HKD1.000054,444
93 Jan 25HKD1.000031,095
1017 Jan 25HKD1.000085,032
1121 Jan 25HKD1.000051,438
1218 Feb 25HKD86,394
1321 Feb 25HKD1.0000170,065
143 Oct 24USD1.000011,841
1529 Aug 25USD1.000010,057
1630 Jun 25HKD1.000096,652
1730 Sep 24USD1.000055,892
1820 Aug 25USD1.000014,348
19
2055,89224 09 USD55,892 USD Sep 24
2131,57124 10 HKD31,571 HKD Oct 24
2218,24824 10 USD18,248 USD Oct 24
2342,57524 12 HKD42,575 HKD Dec 24
2453525 01 CNY535 CNY Jan 25
25167,56525 01 HKD167,565 HKD Jan 25
26224,50925 02 HKD224,509 HKD Feb 25
27108,09925 04 HKD108,099 HKD Apr 25
2896,65225 06 HKD96,652 HKD Jun 25
2924,40525 08 USD24,405 USD Aug 25
Summary
Cell Formulas
RangeFormula
N20:N29N20=SORT(UNIQUE(FILTER(TEXT(F$1:F$19, "yy mm ")&H$1:H$19, J$1:J$19 <> "")))
Q20:Q29Q20=--SORT(LEFT((UNIQUE(FILTER(DATE(YEAR(F$1:F$19),MONTH(F$1:F$19),1)&H$1:H$19,J$1:J$19<>""))),5))
M20:M29M20=SUMPRODUCT((J$1:J$19<>"")*(TEXT(F$1:F$19,"yy mm ")&H$1:H$19=N20)*L$1:L$19)
Dynamic array formulas.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Your edit of Fluff's formula can be edited to sort properly.

Did you try the Pivotby with the Filter Array parameter?
 
Upvote 0
Since I can’t work out how to avoid adding columns, I have put this formula in T20 (first available blank helper column) :
Excel Formula:
=RIGHT(SORT(UNIQUE(FILTER(TEXT(F1:F19,"yy mm")&H1:H19,J1:J19 <> ""))),3)
Then this in N20 :
Excel Formula:
=--SORT(LEFT((UNIQUE(FILTER(DATE(YEAR($F$1:$F$19),MONTH($F$1:$F$19),1)&$H$1:$H$19,$J$1:$J$19<>""))),5))
And this in M20 :
Excel Formula:
=SUMPRODUCT(($J$1:$J$19<>"")*(DATE(YEAR($F$1:$F$19),MONTH($F$1:$F$19),1)=N20)*($H$1:$H$19=T20)*L$1:L$19)

The above works but I would still like to find a way to avoid the helper column.
 
Upvote 0
Correction. The formula in M20 should be :
Excel Formula:
=TEXT(SUMPRODUCT(($J$1:$J$19<>"")*(DATE(YEAR($F$1:$F$19),MONTH($F$1:$F$19),1)=N20)*($H$1:$H$19=T20)*L$1:L$19),"#,##0 ")&T20
 
Upvote 0
How about
Excel Formula:
=LET(a,GROUPBY(FILTER(HSTACK(DATE(YEAR(F2:F18),MONTH(F2:F18),1),H2:H18),J2:J18<>""),FILTER(L2:L18,J2:J18<>""),SUM,,0),HSTACK(TEXT(INDEX(a,,3),"#,000")&" "&INDEX(a,,2),INDEX(a,,1)))
 
Upvote 0
Solution
How about
Excel Formula:
=LET(a,GROUPBY(FILTER(HSTACK(DATE(YEAR(F2:F18),MONTH(F2:F18),1),H2:H18),J2:J18<>""),FILTER(L2:L18,J2:J18<>""),SUM,,0),HSTACK(TEXT(INDEX(a,,3),"#,000")&" "&INDEX(a,,2),INDEX(a,,1)))
That's great! Many thanks.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,875
Messages
6,175,117
Members
452,613
Latest member
amorehouse

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