Graphing decreasing COUNT as dates approach end date

BlackrazorNZ

New Member
Joined
May 18, 2014
Messages
15
Hi all,

I have a table containing a large number of items which have an expected date of full repayment as a calculated field.

I'm trying to work out a measure for a chart, that shows a value for a COUNT of all the fields between the date itself and the final date.

So if the there are 100 items, first of which is repaid on 1st March 2015, and the last of which is repaid on 1st June 2018, then :
  • The graph would show a count of 100 items at the 1st March 2015 point, and;
  • Would show 1 item on 1st June 2018, and;
  • Would show a decreasing scale between the two as the count between any given date and the last date decreases.

Example of what I want the graph to look like (excuse my amazing MS Paint skills) :

Untitled_zps33ff04eb.png


And here's what the graph looks like with a COUNT function (rather than a rolling decreasing SUM of COUNT which is what I want to try and achieve).

count_zpsf8c980ce.png


Thanks for any help :)
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Secondary question : How do you group by date clusters (month, quarter, half year, year etc) in PowerPivot Charts? Was a built in function in basic PivotCharts...
 
Upvote 0
Love the question and mad Paint Skillz :)


Pretty much anytime you are dealing with dates, you are going to have a separate Calendar/Dates table. That is where you will define months, quarters, weeks, etc.
Understand and create date tables in Power Pivot in Excel 2013 - Excel


Your primary question is an interesting reversal of the typical YTD formulas. I'm not at my machine right now to test, but I *think* you will end up with something like:

=CALCULATE([NumPayments], FILTER(ALL(Calendar), Calendar[DateKey] >= Payments[DateKey]))


Where [NumPayments] is however you do your COUNT() and Calendar is your hot new calendar table, with a relationship back to your Payments table.


When that doesn't work, let me know... and I will figure it out when I'm at my computer :)
 
Upvote 0
Hey, thanks for the reply.

Have tried inputting the formula you suggested, and it gives me values, but they're not anywhere near as high as expected. For example, there are 90+ separate date values in the column i'm counting, and 5000-ish records in total, but the highest value returned is 13?

Also, oddly, it works perfectly as a calculated formula in PowerPivot itself, but breaks when I try and add it as a Measure to a PivotChart.
 
Last edited:
Upvote 0
For clarity, what I'm after (conceptually) is :

Area graph, where each value is equal to : the count of 'all rows where the date in field X is at least equal to field X of this row'.

Each row is a record of 1 item. A single item only has one date but one date can have many items.

For each output value I want a simple number, and it should decline as dates proceed forward.
 
Last edited:
Upvote 0
Sorry for the delay. Which ever of these should do what you want:

=CALCULATE([NumPayments], DATESBETWEEN(Calendar[DateKey], MIN(Calendar[DateKey]), LASTDATE(ALL(Calendar[DateKey]))))
=CALCULATE([NumPayments], FILTER(ALL(Calendar), Calendar[DateKey] >= MIN(Calendar[DateKey])))

Btw, this assumes that the date field you put on your chart comes from the Calendar table as well.
 
Upvote 0
Thanks for that. The actual formula I put in is :

=CALCULATE([Barcodes], DATESBETWEEN('Date Range'[Date],MIN('Date Range'[Date]), LASTDATE(ALL('Date Range'[Date]))))

... which doesn't work and instead produces the following error :
"The value for 'Barcodes' cannot be determined. Either 'Barcodes' doesn't exist, or there is no current row for a column named 'RowCount'."

If I change the [Barcodes] to COUNT[Barcodes] like so :

=CALCULATE(COUNT([Barcodes]), DATESBETWEEN('Date Range'[Date],MIN('Date Range'[Date]), LASTDATE(ALL('Date Range'[Date]))))

... the formula works and produces a lovely graph, but it doesn't show it as a declining total :

nondecline_zps59b074b6.png


So close and yet so far! Any idea what's preventing it from tallying the way your formula suggests it should?
 
Upvote 0
Hmmm.... My [NumPayments] was just a measure := COUNTROWS(Payments), but using COUNT(Payments[Barcode]) should give the same results (I'm calling the TABLE, "payments").

The quarters in your horizontal axis... its from the 'Date Range' table?
 
Upvote 0
Yes. Indicative outline is below, this extends all the way to 2150.

[TABLE="width: 331"]
<colgroup><col><col span="4"></colgroup><tbody>[TR]
[TD]Date[/TD]
[TD]Year[/TD]
[TD]Month[/TD]
[TD]Day[/TD]
[TD]Quarter[/TD]
[/TR]
[TR]
[TD="align: right"]26/05/2014[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]26[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]27/05/2014[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]27[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]28/05/2014[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]28[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]29/05/2014[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]30/05/2014[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]31/05/2014[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]31[/TD]
[TD="align: right"]2[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,996
Messages
6,175,862
Members
452,676
Latest member
woodyp

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