Forum Discussion

russell80's avatar
russell80
Helper III
5 years ago
Solved

Help With Event In Progress Visualization

I'm trying to create a stacked column chart which shows for each day over the last 28 days (or a period defined by a slicer) how many records were created, closed or in progress each day. The records are held in a table which has a date column for "date created" and "date closed" (which is blank if in progress).

 

I've followed the guide on daxpatterns for events in progress to create a measure to count the number of records which were in progress each day (https://www.daxpatterns.com/events-in-progress).

 

My measure

 

# Event In Progress = 
VAR MinDate = MIN ( 'Date_table'[Date] )
VAR MaxDate = MAX ( 'Date_table'[Date] )
VAR Result =
CALCULATE (
COUNTROWS ( ft_records ),
ft_records[Created Date] <= MaxDate,
ft_records[Closed Date] > MinDate
|| ISBLANK ( ft_records[Closed Date] ),
REMOVEFILTERS ( 'Date_table' )
)
RETURN
Result

 


 

I created subsequent measures to count the created and closed records. The created measure just looked at the "Created Date" column and the closed measure counts the records with a closed state and uses the "last update" column to get the closed date.

 

Adding these 3 measures to the values of the stacked column chart visual and the date_table date to the axis, I get the visual I'm looking for (a stacked column for each day over the last 28 days showing the count of created, open & closed records for each day) but I'm not getting the interation I want from the visual. I want to be able to select on the chart the create/open/closed record count on a specific day and then filter a table with the records on it to show just those selected e.g. all records closed 14 days ago.

 

This has really got me stupmed and I'm not sure how to move forward from here, so any help would be welcome.

 

  • Howdy!

     

    Thank you for the apology.  🙂

    I found this article that might interest you.  But I took a simpler approach to the problem.  Here's the code:

     

    Events Open in Period = 
        VAR EventsCreated =
            CALCULATETABLE(
                VALUES(ft_records[Record_ID]),
                FILTER(
                    ALL(ft_records),
                    ft_records[Start Date] <= MAX(Date_table[Date])
                )
            )
        VAR EventsPreviouslyClosed =
            CALCULATETABLE(
                VALUES(ft_records[Record_ID]),
                FILTER(
                    ALL(ft_records),
                    ft_records[Finish Date] < MIN(Date_table[Date])
                )
            )
        RETURN
    
        COUNTROWS(
            EXCEPT(
                EventsCreated,
                EventsPreviouslyClosed
            )
        )

     

    What we're doing here is creating a couple of table variables.  The first one is all events opened on or before the last date in a month.  The second is all events closed prior to the month in question.  I'm working with the assumption that an event will be open - even if only for an instant - if it happened to be closed on the same day.  The EXCEPT() function returns rows from one table that are not found in the other, and then we just count the rows.  Here's what the result looks like.

     

    I spot checked this in Excel by manually counting records for June and July and it appears accurate.  But you should probably check a little more just to be sure.

     

    You can download the PBIX here.

20 Replies