Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Divide by Count using a slicer

Hi,

 

I have a table that contains the columns hours & the week number of these hours.

 

I have a slicer using week number. If I select in the slicer for example -

 

Weeks 1 to 8

 

I want to divide the total hours offered in these weeks by 8. (Count of week number)

If I select Weeks 3 to 6 I want to divide total hours offered by 4 etc...

 

Tried using ALLSELECTED but this doesn't work.

  • Anonymous try following measure

     

    Avg = 
    DIVIDE ( 
    SUM ( Table[Hours] ), 
    COUNTROWS ( VALUES ( Table[WeekNumber] ) ) 
    )

     

  • I agree with the solution above as well.  The table shown to the right is the raw data.  The slicer limits the number of rows and associated Hours to the MEASURE.  If this doesn't work, I'm assuming there's more to your raw data than just these two rows.  Can you post a sample please.
    FOrrest

     

3 Replies

  • Anonymous try following measure

     

    Avg = 
    DIVIDE ( 
    SUM ( Table[Hours] ), 
    COUNTROWS ( VALUES ( Table[WeekNumber] ) ) 
    )

     

  • fhill's avatar
    fhill
    Icon for Resident Rockstar rankResident Rockstar

    I agree with the solution above as well.  The table shown to the right is the raw data.  The slicer limits the number of rows and associated Hours to the MEASURE.  If this doesn't work, I'm assuming there's more to your raw data than just these two rows.  Can you post a sample please.
    FOrrest

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Perfect. Works a treat. Thanks a million.