Forum Discussion

dlix's avatar
dlix
New Member
4 years ago
Solved

Dynamically graphing events based on dates

Hello, I have a table listing a number of events with the corresponding start and end dates and other attributes, e.g.:   id start_date end_date country type public e01 2021/03/13 202...
  • dlix's avatar
    dlix
    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