Forum Discussion
Dynamically graphing events based on dates
- 4 years ago
Thanks, that's an interesting approach. This can minimize the space used to store the data and would keep the initial table "clean" for other calculations.
Playing around with measures, I think I've found a possible solution using just the original data:
Count of id in month = VAR __SELECTED = SELECTEDVALUE( 'months'[month]) VAR __MONTH_START = DATE( YEAR( __SELECTED), MONTH( __SELECTED), 1) VAR __MONTH_END = EOMONTH( __SELECTED, 0) RETURN CALCULATE( COUNTA( 'events'[id]), 'events'[start_date] <= __MONTH_END, 'events'[end_date] >= __MONTH_START )It needs a "months" table with a list of the nonths to be represented in the chart:
month
2021/03/01 2021/04/01 2021/05/01 (etc...) This seems quite fast and flexible as I can easily create different measure for different views (e.g. events starting and ending in the same month, new events for the month, etc.), but I'm not sure if it solid enough or if it will bring any issue while I proceed with the implementation.
One problem my solution has compared to your proposal is that it returns just a single value for each data point so I can't use the "show data point as a table" menu or navigate the data.
I will probably try to implement both on the real data and see which one suits better the reporting objectives.
Thanks a lot
I thought aboutit some more - it might be better to separate both tables - the event header table and the eventmonths table. That way you save on storage and can do easier reporting on header level.
Thanks, that's an interesting approach. This can minimize the space used to store the data and would keep the initial table "clean" for other calculations.
Playing around with measures, I think I've found a possible solution using just the original data:
Count of id in month =
VAR __SELECTED = SELECTEDVALUE( 'months'[month])
VAR __MONTH_START = DATE( YEAR( __SELECTED), MONTH( __SELECTED), 1)
VAR __MONTH_END = EOMONTH( __SELECTED, 0)
RETURN
CALCULATE( COUNTA( 'events'[id]),
'events'[start_date] <= __MONTH_END, 'events'[end_date] >= __MONTH_START
)
It needs a "months" table with a list of the nonths to be represented in the chart:
month
| 2021/03/01 |
| 2021/04/01 |
| 2021/05/01 |
| (etc...) |
This seems quite fast and flexible as I can easily create different measure for different views (e.g. events starting and ending in the same month, new events for the month, etc.), but I'm not sure if it solid enough or if it will bring any issue while I proceed with the implementation.
One problem my solution has compared to your proposal is that it returns just a single value for each data point so I can't use the "show data point as a table" menu or navigate the data.
I will probably try to implement both on the real data and see which one suits better the reporting objectives.
Thanks a lot
- lbendlin4 years agoSuper User
One other issue with the measure approach is that it needlessly recomputes all the time. Your data is immutable and doesn't need recomputing.