• 593K Members
• 10.8K Online
• 720K Conversations
SOLVED

Highlighted
Contributor

# Running total in Pivot table (Monthwise incrementation by distinct count)

Dear Experts,

I need help regarding running total in pivot.

Please find the attachement and it is better explained there.

15 Replies
Highlighted
Solution

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , that's not the same as in your table. If you have distinct count for the one month and another one, total distinct count won't be a sum since some suppliers are repeated in full period. Thus total for two months shall be less than sum of distinct count for each of two months. With that logic that is like

```DistinctCountSuppliersTotal:=CALCULATE (
DISTINCTCOUNT([Supplier No.]),
FILTER ( ALL ( Table1 ), Table1[Purchase date] <= MAX (Table1[Purchase date] ) )
)```

If distinct count only for the year

```DistinctCountSuppliers:=CALCULATE (
DISTINCTCOUNT([Supplier No.]),
FILTER ( ALLEXCEPT ( Table1,Table1[Year] ), Table1[Month] <= MAX (Table1[Month] ) )
)```

Or you assume another logic?

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Sergei Baklan Thank you for your quick response.

Yes that is correct but now the problem is when I apply it to my original file it is somehow not working.

For confidential reason I did extract some elements which I uploaded.

See in the picture.

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , bit hard to recognize on screenshort was is wrong, I added these metrics for your model, please see third sheet attached.

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , perhaps I misunderstood you. "Not working" means wrong formula syntax, or wrong result calculated by that formula?

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Sergei Baklan  I mean wrong calculations. What I see is it is not counting the distinct numbers.

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Sergei Baklan Can you please delete this post as it contains some confidential information and I dont want to be use in public. Thank you for you understanding.
Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , I removed formulas and attachment, hope it is enough

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , I'll check distinct count calculations by another way. But let agree first - you'd like running distinct count over periods (e.g. in March 2019 we have total distinct count from Jan 2018 to Feb 2019 includes), or we start running total for each new year from scratch; or we sum distinct counts for each month ignoring what some could be repeated in full period.

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Sergei Baklan Yes I want running distinct count over period. as you mentioned in exp. like in March 2019 we should have a sum of distinct count from Jan and Feb and so on at the end.

(At the end grand total should also sum distinct count for the whole year if possible)

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , and if we go from one year to another, we take yellow variant?

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

Yes that will be great!
Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , okay, for the yellow variant you shall add one more column into your data model, let say DateKey, as

`=[Year]*100+[Month]`

and modify previous formula as

```DistinctCountSuppliers:=CALCULATE (
DISTINCTCOUNT([Supplier No.]),
FILTER ( ALL ( Table1 ), Table1[DateKey] <= MAX (Table1[DateKey] ) )
)```

Didn't test it, will illustrate on the sample some later

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , that's in Sheet3 attached based on your sample data

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Sergei Baklan Thank you so so much for your time and support.

Highlighted

# Re: Running total in Pivot table (Monthwise incrementation by distinct count)

@Ubaid ur Rahman , you are welcome

Related Conversations
Counting Days
Tim Hunter in SQL Server on
2 Replies
How to count multiple values in a cell
Ugarte335 in Excel on
7 Replies
Count until
MBelshaw in Excel on
1 Replies
Pivot table
gabriellerocha in Excel on
5 Replies
PivotTable : Unexpected behavior with 2 tables
CastyChichi in Excel on
2 Replies