Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sum Index Match Months from Quarter/Year Input

I have a table in the following format:

Version 1 Version 2 Version 3 Version 4
Jan 2023 Value Value Value Value
Feb 2023 Value Value Value Value
Mar 2023 Value Value Value Value
Apr 2023 Value Value Value Value
May 2023 Value Value Value Value
Jun 2023 Value Value Value Value
Jul 2023 Value 200 Value Value
Aug 2023 Value 100 Value Value
Sep 2023 Value 150 Value Value
Oct 2023 Value Value Value Value
Nov 2023 Value Value Value Value
Dec 2023 Value Value Value Value

I am looking trying to sum the intersect where input variables:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

a) Q3 2023

b) Version 2

I have tried:

=SUMPRODUCT((A2:A13>=DATE(YEAR(F1),CHOOSE(MATCH(F1,{"Q1","Q2","Q3","Q4"},0)*3-2,1,4,7,10),1))*
  (A2:A13<=EOMONTH(DATE(YEAR(F1),CHOOSE(MATCH(F1,{"Q1","Q2","Q3","Q4"},0)*3,3,6,9,12),1),0))*
 (INDEX(B2:E13,0,MATCH(G1,B1:E1,0)))


This doesn’t work because of comparing text and dates. I am not opposed to using helper lookup tables to get the months for each quarter but i am stumped.


Output should be 450.

>Solution :

Try one of the following as I have commented above:

• Formula 1

=SUMPRODUCT(IFERROR(
  (A2:A13>=DATE(RIGHT(F1,4),CHOOSE(TOCOL(MATCH({"Q1*","Q2*","Q3*","Q4*"},F1,0)*3,3),1,4,7,10),1))*
  (A2:A13<=EOMONTH(DATE(RIGHT(F1,4),CHOOSE(TOCOL(MATCH({"Q1*","Q2*","Q3*","Q4*"},F1,0)*3,3),3,6,9,12),1),0))*
  (INDEX(B2:E13,0,MATCH(G1,B1:E1,0))),0))

Or,

• Formula 2

=SUMPRODUCT(IFERROR(
  (A2:A13>=DATE(RIGHT(F1,4),CHOOSE(MATCH(LEFT(F1,2),{"Q1","Q2","Q3","Q4"},0),1,4,7,10),1))*
  (A2:A13<=EOMONTH(DATE(RIGHT(F1,4),CHOOSE(MATCH(LEFT(F1,2),{"Q1","Q2","Q3","Q4"},0),3,6,9,12),1),0))*
  (INDEX(B2:E13,0,MATCH(G1,B1:E1,0))),0))

enter image description here


Or if you are using MS365 then can use the following formula:

enter image description here


• Formula used in cell G3

=SUM(
    TOCOL(
        (
            "Q" &
                ROUNDUP(
                    MONTH(
                        A2:A13
                    ) / 3,
                    0
                ) & " " &
                YEAR(A2:A13) =
                F1
        ) * (G1 = B1:E1) *
            (B2:E13),
        3
    )
)

Or,

=SUM(TOCOL(("Q"&INT((MONTH(A2:A13)-1)/3)+1=LEFT(F1,2))*(G1=B1:E1)*(B2:E13),3))

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading