Pivot Table

alag76

New Member
Joined
May 18, 2006
Messages
24
Hi everyone,

Can I use a Pivot Table to return the number of records meeting a specific criteria? In the screenshot example, I would like to have an additional pivot table column that shows the number of records where the days outstanding that are greater than 14 days for each ID number. For example, for ID number 2 it would be 3 since there are 3 records with 15. Thank you!!
 

Attachments

  • 2021-10-04 17_31_23-Window.png
    2021-10-04 17_31_23-Window.png
    27.7 KB · Views: 5

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Cannot manipulate data in a picture. Please represent using XL2BB so that we don't have to recreate your file to figure out a solution for you.
 
Upvote 0
Book1
ABCDEFGH
1Site IDQuery IDDays OutstandingRow LabelsCount of Query IDDays outstanding >14
2212252
3222485
4232581
52415693
62515Grand Total3011
74610
84710
94810
1049100
11410100
12411100
13412100
14413100
155146
165156
175166
185176
195186
205196
215206
2252199
236227
246237
256247
266257
276267
286277
2962820
3062920
3163020
Sheet1
Cell Formulas
RangeFormula
H6H6=SUM(H2:H5)
 
Upvote 0
Here is a Power Query Solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Site ID", Int64.Type}, {"Query ID", Int64.Type}, {"Days Outstanding", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if[Days Outstanding]>14 then 1 else null),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Site ID"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"Days > 14", each List.Sum([Custom]), type nullable number}})
in
    #"Grouped Rows"

Book6
FGH
1Row LabelsCount of Query IDDays outstanding >14
2252
3485
4581
5693
6Grand Total3011
7
8Site IDCountDays > 14
9252
10485
11581
12693
Sheet1
Cell Formulas
RangeFormula
H6H6=SUM(H2:H5)
 
Upvote 0
Here is a Power Query Solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Site ID", Int64.Type}, {"Query ID", Int64.Type}, {"Days Outstanding", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if[Days Outstanding]>14 then 1 else null),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Site ID"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"Days > 14", each List.Sum([Custom]), type nullable number}})
in
    #"Grouped Rows"

Book6
FGH
1Row LabelsCount of Query IDDays outstanding >14
2252
3485
4581
5693
6Grand Total3011
7
8Site IDCountDays > 14
9252
10485
11581
12693
Sheet1
Cell Formulas
RangeFormula
H6H6=SUM(H2:H5)
Thank you! I'm not familiar with PowerQuery but I will research on how to add.
 
Upvote 0
FYI

Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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