Forum Discussion
Cumulative double line chart operating on dates
Hi,
I have a table with a list of items with a "target date" and an "actual date" (or blank) associated.
As you can see from the attached image, I use a slicer to filter the visuals by the year of the target dates. This way I get a chart with a bar showing the total number of items (a COUNT) with a target date in the selected year and a bar showing the total number of items with an actual date in the selected year. The second chart shows the same information, but drilled to each single month of the year.
I need to add a double line chart showing the same values of the second chart (the monthly chart), but with cumulative values (COUNT). So, for instance, the February "target date" value will be the count of all the items with a target date included in both January and February and so on.
I couldn't find a working solution by looking to other posts, so I ask for your help.
Thank you.
Hi Sixian,
Based on the Anonymous's solution, you can try this one.
Items running total = CALCULATE ( COUNT ( 'Table'[Item] ), FILTER ( ALLSELECTED ( 'Table'[MonthNumber] ), ISONORAFTER ( 'Table'[MonthNumber], MAX ( 'Table'[MonthNumber] ), DESC ) ) )I would suggest you create a date table if you don't have one.
Measure = CALCULATE ( COUNT ( 'table'[item] ), FILTER ( ALLSELECTED ( 'datetable' ), 'datetable'[date] <= MAX ( 'datetable'[date] ) ) )Or please share a sample file? Mask the sensitive parts first.
Best Regards,
Dale
5 Replies
- AnonymousNot applicable
Have you tried creating a running total column or measure?
Make sure you have a column 'MonthNumber' which corresponds to the number of the month (1 for Jan, 2 for Feb etc.)
Items running total =
CALCULATE(
SUM('Table'[ItemCount]),
FILTER(
ALLSELECTED('Table'[MonthNumber]),
ISONORAFTER('Table'[MonthNumber], MAX('Table'[MonthNumber]), DESC)
)
)- SixianFrequent Visitor
Sorry.
What do you mean for
'Table'[ItemCount]
?
We can suppose we just have a table with the three columns: |item|target date|actual date|
The 'Table' should be this table with all the items and dates, but what column is [ItemCount]?
- SixianFrequent VisitorI tried to understand and apply the suggestion, but the chart shows nothing.
Any help would be greatly appreciated.- v-jiascu-msftMicrosoft Employee
Hi Sixian,
Based on the Anonymous's solution, you can try this one.
Items running total = CALCULATE ( COUNT ( 'Table'[Item] ), FILTER ( ALLSELECTED ( 'Table'[MonthNumber] ), ISONORAFTER ( 'Table'[MonthNumber], MAX ( 'Table'[MonthNumber] ), DESC ) ) )I would suggest you create a date table if you don't have one.
Measure = CALCULATE ( COUNT ( 'table'[item] ), FILTER ( ALLSELECTED ( 'datetable' ), 'datetable'[date] <= MAX ( 'datetable'[date] ) ) )Or please share a sample file? Mask the sensitive parts first.
Best Regards,
Dale- SixianFrequent Visitor
I'm now using the date table and following the new instructions. I'm getting close, but the numbers are still not exact. May be there is something in the filters. I'll let you know.
Thanks for now.