Forum Discussion
Create Table that Counts Items According to Calendar Dates
My situation is the following:
I have a main data table that looks like this:
| Appended Table | ||
| Work Item ID | Created Date | Closed Date |
| 1 | 1/1/2021 | 4/1/2021 |
| 2 | 3/1/2021 | |
| 3 | 5/1/2021 | 6/1/2021 |
| 4 | 6/1/2021 | 7/1/2021 |
| 5 | 12/1/2021 |
I also created a calendar table using this code:
| First of Month | OpenMonthly | ClosedMonthly |
| 1/1/2021 | 1 | 0 |
| 2/1/2021 | 1 | 0 |
| 3/1/2021 | 2 | 0 |
| 4/1/2021 | 0 | 1 |
| 5/1/2021 | 2 | 0 |
| 6/1/2021 | 2 | 1 |
| 7/1/2021 | 1 | 1 |
| 8/1/2021 | 1 | 0 |
| 9/1/2021 | 1 | 0 |
| 10/1/2021 | 1 | 0 |
| 11/1/2021 | 1 | 0 |
| 12/1/2021 | 2 | 0 |
The goal is to be able to create simple charts showing how many projects are opened a closed monthly. Could someone help with what code I need to write to reach the result in the table above?
4 Replies
- bcdobbs
Community Champion
Normally I'd lean towards just a measure but does this do what you want for the open monthly:
Open Monthly = VAR tblOpen = FILTER ( 'Appended Table', 'Appended Table'[Created Date] <= EOMONTH('ADO Metrics'[First of Month], 0 ) && 'Appended Table'[Created Date] >= 'ADO Metrics'[First of Month] ) RETURN COUNTROWS ( tblOpen )
If it's what you're looking for I can write a similar expression for closed but it's the same logic.- AnonymousNot applicable
While that did work to count the number of 'Work Item ID's that were created and closed each month, what I am trying to do is understand how many are opened and remain open each month.
For example, when the system was launched our first 'Work Item ID' was recorded on 9/17/2017 so the data is showing "1" for the month of 9/17. However, when you look at the next month on the table (10/17) there is no data. It should still be counting that the 'Work Item ID' as open, because it does not yet have a "Closed Date".
For example let's say I have four projects with following open/closed dates:
#1 Opened 9/1/2017 - Closed 11/1/2017
#2 Opened 10/1/2017 - Closed 11/1/2017
#3 Opened 10/1/2017 - NOT CLOSED
#4 Opened 12/1/2017 - NOT CLOSED
I'd expect to see
First of Month OpenMonthly 1/1/2017 0 2/1/2017 0 3/1/2017 0 4/1/2017 0 5/1/2017 0 6/1/2017 0 7/1/2017 0 8/1/2017 0 9/1/2017 1 10/1/2017 3 11/1/2017 1 12/1/2017 2 I hope that makes sense!
Thanks!- bcdobbs
Community Champion
No worries what about this:
Open Monthly = VAR tblOpen = FILTER ( 'Appended Table', 'Appended Table'[Created Date] <= 'ADO Metrics'[First of Month] && ( 'Appended Table'[Closed Date] > EOMONTH ( 'ADO Metrics'[First of Month], 0 ) || ISBLANK ( 'Appended Table'[Closed Date] ) ) ) RETURN COUNTROWS ( tblOpen ) + 0