Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Showing Quarters in reports

Hi all,  What I have is a list of projects witih tables Project name start date end date   So what I would like have is the possibility to choose a quarter (ex. Q2 2019) and it would show...
  • Grambi's avatar
    6 years ago

    1. I would create a date table:

     

    DIM_DATE = CALENDAR(FIRSTDATE('start date');LASTDATE('end date'))

     

    2. Add a column to that table for quarter:

     

    Quarter = format(DIM_DATE[Date];"YYYY")&"-Q"&format(DIM_DATE[Date];"Q")

     

    3. Create a slicer based on the quarter field. Select for example 2019-Q2, so you can test the output.

    4. Now add the following measure to your original projects table

     

    Project_active_in_selected_quarter = var _firstdate = STARTOFQUARTER(DIM_DATE[Date])
    var _lastdate = ENDOFQUARTER(DIM_DATE[Date])
    return if(or(FIRSTDATE(Projects['start date'])>_lastdate;FIRSTDATE(Projects['end date'])<_firstdate);"inactive";"active")

     

    This measure finds the start and end date of the selected quarter from your slicer.  It then checks whether the project ends before the start of the quarter, or if the project starts after the end of the quarter. If so, it's "inactive". If not, it returns "active".

    It's not really designed to support for selection of multiple quarters. If the user selects multiple quarters, for example Q2 and Q4-2019, the measure will check if the project is active in the time between April 1 2019 and December 31 2019. So projects that are only active in Q3 will also be labeled as active.

    5. Add this measure to a table containing the projects and check the output.