Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Daily Count By Category

I am trying to track the progression of some projects and the different cycles of developemnt they go through. For example I would like to see in a line chart with a line for each cycle and see the c...
  • Anonymous's avatar
    Anonymous
    7 years ago
    Evening v-lid-msft,
     
    Sorry for the confusion I will try to be a little more descriptive in my next post. The three types in the example map to the `phase text` which roll up into a high types which I call `Phase` or `business phase` in the new file, which is a calculated column.  
     
    So here are the steps I went through to find the solution. I don't think this is the only way, or correct way but it works.
    1. I added a month column to the test table that classifies all dates in a month to the first day of the month.
    Month = date(Year('test measure'[created_datetime]) ,month('test measure'[created_datetime]),1)
    2. I created a table with all the first days of the months between min and max dates.
    Table 6 = 
    
    var dateTable2 =
        GENERATE ( CALENDAR(
        DATE ( YEAR ( MIN ( 'test measure'[created_datetime]) ), 1, 1 ),
        DATE ( YEAR ( MAX ( 'test measure'[created_datetime])  ), 12, 1 )),
        VAR currentDay = [Date]
        VAR month = MONTH ( currentDay )
        VAR year = YEAR ( currentDay )
        RETURN ROW ( 
        "MMYYDD", DATE(year,month,01) )
        )
    
    return groupby(dateTable2,[MMYYDD])
    3. Then I cross joined all project_id's with these dates to create another table.
    Table 7 = filter(crossjoin('Table 6',DISTINCT(SELECTCOLUMNS('test measure',"ID",'test measure'[project_id]))),[ID]<>"#N/A")
    4,Once I had this table I looked up the phase for a specific project where the max date for that project was less than or equal to the current row date.
    Solution = ADDCOLUMNS('Table 7',"PHASE",LOOKUPVALUE('test measure'[phase_text],'test measure'[project_id],[ID],'test measure'[created_datetime],maxx(filter('test measure','test measure'[project_id]='Table 7'[ID] &&'test measure'[Month]<=earlier('Table 7'[MMYYDD])),[created_datetime]))) 
     
    Here is the file