Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Measure - Average time per category per task

Hello all,

I'd like to build stacked chart with Average resolution time for  category per month per Task distinct count. Here is my data in Table ForAnalysis:

 

ForAnalysis
TaskMonthCategoryTime
N1Jan-2015
N1Jan-2021
N1Jan-2033
N2Jan-2015
N2Jan-2012
N2Jan-2024
N3Feb-2016
N3Feb-2021
N3Feb-2013
N3Feb-2035
N4Feb-2012
N4Feb-2023
N4Feb-2012
N4Feb-2031
N4Feb-2031

 

The result per category and distinct Task number per month:

 

 Average
Jan Catego 16
Jan Catego 22.5
Jan Catego 3 3
Feb Catego 16.5
Feb Catego 22
Feb Catego 32.33

 

Here is how I want to calculate it: Category 1 has 3 row / value in January meaning this is 5+5+2 = 12 and now I divide it per distinct Task count in January 12 / 2 = 6. This is how I come up with my average category per month per task. Respectively for other Categories.

 

Seems simple but somehow I can't figure it out trying different Measures based on Averages, CALCULATE and few others.
Any help much appreciated.

Thanks Evo

  • Anonymous's avatar
    Anonymous
    5 years ago

    Anonymous 

    I think the easiest way would be to, simply, add a quick measure "Weighted Average per Category" . I tested with your sample data, and confirmed that it genrates the expected results. Hope it helps.

       

    OR  

     

    Then, select "Weighted Average per category" from the dropdown, and fill out the rest as follows:

     

    Here are the results I got:

    p.s. By default, the results are given in whole numbers. If you want to include decimals, make sure to update the visual to include decimals.
    I hope this resolves the issue you're facing.
    Thanks.

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous 

    I think the easiest way would be to, simply, add a quick measure "Weighted Average per Category" . I tested with your sample data, and confirmed that it genrates the expected results. Hope it helps.

       

    OR  

     

    Then, select "Weighted Average per category" from the dropdown, and fill out the rest as follows:

     

    Here are the results I got:

    p.s. By default, the results are given in whole numbers. If you want to include decimals, make sure to update the visual to include decimals.
    I hope this resolves the issue you're facing.
    Thanks.

  • fhill's avatar
    fhill
    Resident Rockstar

     

    Break this up into indivual measures, makes it much eaiser...  

     

    SUM_Time = SUM('Table'[Time])
    DIST_Count_Tasks = DISTINCTCOUNT('Table'[Task])
    Measure = [SUM_Time] / [DIST_Count_Tasks]
     
     

  • Anonymous ,

    Try a measure

    divide(sum(Table[Time]), distinctcount(Table[Task]))

     

    or

     

    Averagex(summarize(Table, Table[Month] , Table[Category],"_1",divide(sum(Table[Time]), distinctcount(Table[Task]))),[_1])

    • Anonymous's avatar
      Anonymous
      Not applicable

      Unfortunately neither of those works.

      The first one sums up all the averages across the table and then divide it by distinct count per month and the other results in some strange results I even can't interpret.

       

      Thanks

      E