Forum Discussion
Help With Event In Progress Visualization
- 5 years ago
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.
This may not be the ideal solution but it does what I need and I'm pretty chuffed I managed to figure this out 👍
I re-read the article I posted in the first post and it talked about creating a table first to help do with the calculations, so that's what I tried. I created 3 tables using DAX, one for "Created" records, one for "Open" and one for "Closed" and a 4th table (record history) to Union them together. By adding additional columns to the tables to capture the record state and a value for summing in the visual, I got something that works. I had to duplicate the record table so I could create a relationship between it at the "record history" table, so when I clicked on the visual I could get the records associated with the selection (not sure if this has any impact).
You can download the pbix file here: Download
Glad you got it figured out, but that's not a great solution. You're creating tables with duplicate info which wastes memory (everything in Power BI is done in RAM). You may begin to see performance issues as the volume of data grows. What I offered will do it in real time when used in visualizations and otherwise not impact RAM at all.
By the way...if you'd be interested I can offer recommendations for some very good courses on Udemy, etc. that will help you learn Power BI, DAX, etc. This stuff is not easy to learn, and at times very painful 😫.