Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8649653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:36:52+00:00 2026-06-12T13:36:52+00:00

In my Pivot table, I have a data field which I want to be

  • 0

In my Pivot table, I have a data field which I want to be summarized as count. I tried changing the subtotalfunction property to count, but it still shows the sum. Can someone give me an example of how I can do this?

In other words can anyone give me an example of a pivot table in which you can see the count and not the sum.

I’m using EPPlus latest build. 3.1.1

Thanks a lot 🙂

EDIT: This is what I’m trying.

                    var wsPivot = package.Workbook.Worksheets.Add("Pivot");
                    var pivotTable = wsPivot.PivotTables.Add(wsPivot.Cells["A55"], dataRange, "Table");
                    pivotTable.MultipleFieldFilters = true;
                    pivotTable.RowGrandTotals = true;
                    pivotTable.ColumGrandTotals = true;
                    pivotTable.Compact = true;
                    pivotTable.CompactData = true;
                    pivotTable.GridDropZones = false;
                    pivotTable.Outline = false;
                    pivotTable.OutlineData = false;
                    pivotTable.ShowError = true;
                    pivotTable.ErrorCaption = "[error]";
                    pivotTable.ShowHeaders = true;
                    pivotTable.UseAutoFormatting = true;
                    pivotTable.ApplyWidthHeightFormats = true;
                    pivotTable.ShowDrill = true;
                    pivotTable.FirstDataCol = 3;
                    pivotTable.RowHeaderCaption = "Caption";

                    var pageField = pivotTable.Fields["field1"];
                    pivotTable.PageFields.Add(pageField);

                    var rowField = pivotTable.Fields["cust"];                    
                    pivotTable.RowFields.Add(rowField);

                    var dataField = pivotTable.Fields["id"];

                    dataField.SubTotalFunctions = OfficeOpenXml.Table.PivotTable.eSubTotalFunctions.Count;
                    pivotTable.DataFields.Add(dataField);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:36:53+00:00Added an answer on June 12, 2026 at 1:36 pm

    I figured it out. This worked for me

    pivotTable.DataFields.Add(dataField);
    pivotTable.DataFields[0].Function = DataFieldFunctions.Count;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have query to show the table like this: but I want to PIVOT
I have an Excel spreadsheet which has a pivot table on it. The data
I have table to test score data that I need to pivot and I
I have an Events table with a not-null date field. Based on a pivot
I have this great function that parses a field into a pivot table consisting
I have following function that converts normal DataTable to Pivot Table. But I have
I have created a Pivot Table to display my data filtered according to multiple
I currently have a table with all the data, using this data i want
i have some mysql script for pivot table and then counting some data inside
I have a pivot table, well of course every row will be included in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.