sum with criteria coming from another table

vince1985

New Member
Joined
Sep 17, 2015
Messages
16
Office Version
  1. 2016
Platform
  1. Windows
Good afternoon,

I would like to make a sum of values that meet a specific criteria.
The difficulty that this criteria is not a value but a list of values that correspond to a value that i would enter (this correspondence being inside another table). i think that this request is not very explicit so i have made an example, attached.
In this example, I would like to know the total scores of all the students of a given class (that would be the criteria to input manually). The students with their scores being in one table, and the students and their class number being in another table.
I would like to skip the intermediate step of adding up a column in the score table with the students class number.

Do you know how to deal with this kind of issue ?

thank you in advance for your feedback !

Vincent
 

Attachments

  • 2025-01-26 15_42_25-Example - Excel.png
    2025-01-26 15_42_25-Example - Excel.png
    22.7 KB · Views: 7

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Created a parameter query as shown in the attached.

Book3
ABCDEFGHIJKLMNO
1StudentClass numberStudentScoreClassStudentClass numberTotal
2A1C92C236Enter the Class in G2
3B1B17F231Click on Data-->RefreshAll
4C2F18J2Query will update.
5D3G13K2
6E1F13
7F2B15
8G3C13
9H3D0
10I3A11
11J2B13
12K2A3
13L1C14
14M1
15N1
Sheet1


Here is the Mcode

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Source2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    MQ = Table.NestedJoin(Source, {"Student"}, Source2, {"Student"}, "Tbl", JoinKind.FullOuter),
    #"Expanded Tbl" = Table.ExpandTableColumn(MQ, "Tbl", {"Score"}, {"Score"}),
    #"Grouped Rows" = Table.Group(#"Expanded Tbl", {"Student", "Class number"}, {{"Total", each List.Sum([Score]), type nullable number}}),
    #"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Class number] = Table3))

in
    #"Filtered Rows"

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Class = Source{0}[Class]
in
    Class
 
Upvote 0
Thank you very much for your reply ! I will try it now ! Alternatively, do you know whether there are solutions only using Excel functions ?
 
Upvote 0
Is directly like this with a formula what you want?

25 01 26.xlsm
ABCDEFGH
1
2StudentClassStudentScoreClass1
3A1C9Score59
4B1B17
5C2F18
6D3G13
7E1F13
8F2B15
9G3C13
10H3D0
11I3A11
12J2B13
13K2A3
14L1C14
15M1
16N1
Class Score
Cell Formulas
RangeFormula
H3H3=SUMPRODUCT(SUMIF(D3:D14,A3:A16,E3:E14),--(B3:B16=H2))
 
Upvote 0
Solution

Forum statistics

Threads
1,226,063
Messages
6,188,653
Members
453,489
Latest member
jessrw

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