running total in pivot table when grouping dates

%3CLINGO-SUB%20id%3D%22lingo-sub-2172289%22%20slang%3D%22en-US%22%3Erunning%20total%20in%20pivot%20table%20when%20grouping%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2172289%22%20slang%3D%22en-US%22%3Ein%20my%20file%20there%20are%20sums%20in%20the%20context%20of%20dates.%20I%20formed%20a%20pivot%20table%20where%20in%20the%20rows%20of%20the%20date%2C%20in%20the%20columns%20of%20the%20sum.%20I%20need%20to%20output%20the%20running%20total.%20for%20this%2C%20the%20field%20was%20re-displayed%20the%20amount%20and%20made%20an%20additional%20calculation.%20everything%20is%20considered%20fine%2C%20but%20as%20soon%20as%20I%20group%20the%20data%20by%20months%2C%20the%20calculation%20of%20the%20cumulative%20total%20gets%20confused.%20tell%20me%20how%20to%20keep%20the%20running%20total%20in%20the%20pivot%20table%20after%20grouping%20dates%20into%20years%20and%20months%3F%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2172289%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2172442%22%20slang%3D%22en-US%22%3ERe%3A%20running%20total%20in%20pivot%20table%20when%20grouping%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2172442%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F981185%22%20target%3D%22_blank%22%3E%40Elenazhilina%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20grouping%20the%20date%20built-in%20Running%20Total%20resets%20calculations%20from%20the%20beginning%20of%20each%20group.%20To%20calculate%20running%20total%20through%20all%20dates%20you%20need%20to%20add%20data%20to%20data%20model%20and%20create%20the%20measure%20to%20calculate%20it.%3C%2FP%3E%0A%3CP%3EOn%20such%20sample%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20156px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F258751i033EFAEA6412D1FA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ECreating%20PivotTable%20add%20data%20to%20data%20model%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20419px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F258752iC2A6033E93C3B8C5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Eadd%20two%20measures%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3ESum%20Value%3A%3DSUM(Table1%5BValue%5D)%0A%0Aand%0A%0AValue%20Running%20Total%3A%3DVAR%0AMaxDate%3DMAX%20(%20Table1%5BDate%5D%20)%0ARETURN%0A%20%20CALCULATE(%5BSum%20Value%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20Table1%5BDate%5D%26lt%3B%3D%20MaxDate%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20ALL%20(Table1)%0A%20%20)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EInstead%20of%20first%20one%20you%20may%20use%20implicit%20measure%20which%20sums%20value%2C%20but%20better%20to%20keep%20everything%20in%20hands%20and%20use%20explicit%20measures.%3C%2FP%3E%0A%3CP%3EIn%20second%20one%20MaxDate%20will%20be%20maximum%20date%20for%20the%20current%20group%2C%20removing%20all%20other%20filters%20from%20the%20Table%20we%20calculate%20sum%20of%20Value%20till%20MaxDate.%3C%2FP%3E%0A%3CP%3EResult%20is%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20280px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F258753i72C0EDD624AAA0F5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2172473%22%20slang%3D%22en-US%22%3ERe%3A%20running%20total%20in%20pivot%20table%20when%20grouping%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2172473%22%20slang%3D%22en-US%22%3ESo%20I%20need%20to%20have%20Pivot%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2172481%22%20slang%3D%22en-US%22%3ERe%3A%20running%20total%20in%20pivot%20table%20when%20grouping%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2172481%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F981185%22%20target%3D%22_blank%22%3E%40Elenazhilina%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPower%20Pivot%20is%20desirable%20but%20not%20necessary.%20However%2C%20your%20version%20of%20Excel%20shall%20support%20data%20model.%20That%20is%20Excel%20for%20Windows%20Desktop%20starting%20from%202013%20or%202010.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor
in my file there are sums in the context of dates. I formed a pivot table where in the rows of the date, in the columns of the sum. I need to output the running total. for this, the field was re-displayed the amount and made an additional calculation. everything is considered fine, but as soon as I group the data by months, the calculation of the cumulative total gets confused. tell me how to keep the running total in the pivot table after grouping dates into years and months?
6 Replies

@Elenazhilina 

With grouping the date built-in Running Total resets calculations from the beginning of each group. To calculate running total through all dates you need to add data to data model and create the measure to calculate it.

On such sample

image.png

Creating PivotTable add data to data model

image.png

add two measures

Sum Value:=SUM(Table1[Value])

and

Value Running Total:=VAR
MaxDate=MAX ( Table1[Date] )
RETURN
  CALCULATE([Sum Value],
             Table1[Date]<= MaxDate,
             ALL (Table1)
  )

Instead of first one you may use implicit measure which sums value, but better to keep everything in hands and use explicit measures.

In second one MaxDate will be maximum date for the current group, removing all other filters from the Table we calculate sum of Value till MaxDate.

Result is

image.png

So I need to have Pivot?

@Elenazhilina 

Power Pivot is desirable but not necessary. However, your version of Excel shall support data model. That is Excel for Windows Desktop starting from 2013 or 2010.

thank you very much for your answer) I've been struggling with this for the second week. can i show you my file?
it's hard for me to correctly explain and understand you in English ((
I have an array of data. I have compiled it into the pivot table I need. in rows, grouping by counterparties and, as another level, dates. but since the array will grow, I really need a grouping by years and months, so that the cumulative total is visible.

@Elenazhilina 

In general yes, but first please try on copy of your file if you are ready to add data to data model. On any PivotTable click on More fields

image.png

Excel asks to create new PivotTable

image.png

Click Yes, new PivotTable will be created and data added to data model. But you will lost all PivotTable formatting and shall format/group/filter/add slicers from scratch. That's time consuming operation, but better than create new PivotTable from scratch.

Thus I'd suggest you to try on one PivotTable, if it's worth to do such way I'll help to create the measure.

 

I will be very grateful to you. never faced pivot. tomorrow I will definitely try to figure it out. if it doesn't work, with your permission, I'll show you the file. it is very important to get the result