Forum Discussion

MarshalSK's avatar
MarshalSK
Resolver I
2 years ago
Solved

Average per year

Hi Folks, Need quick help to get average. Sharing sample dataset and expected result.

 

DateSales
01-Jan-22100
01-Feb-22125
01-Mar-22150
01-Apr-22175
01-May-22200
01-Jun-22225
01-Jul-22250
01-Aug-22275
01-Sep-22300
01-Oct-22325
01-Nov-22350
01-Dec-22375
01-Jan-22200
01-Feb-22225
01-Mar-22250
01-Apr-22275
01-May-22300
01-Jun-22325
01-Jul-22350
01-Aug-22375
01-Sep-22400
01-Oct-22425
01-Nov-22450
01-Dec-22475
01-Jan-2350
01-Feb-2375
01-Mar-23100
01-Apr-23125
01-May-23150
01-Jun-23175
01-Jul-23200
01-Aug-23225
01-Sep-23250
01-Oct-23275
01-Nov-23300
01-Dec-23325
01-Jan-230
01-Feb-2350
01-Mar-23100
01-Apr-23150
01-May-23200
01-Jun-23250
01-Jul-23300
01-Aug-23350
01-Sep-23400
01-Oct-23450
01-Nov-23500
01-Dec-23550

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi MarshalSK ,

     

    We can create a measure.

    avg = 
    var _sales=CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Table'),'Table'[Date].[Year]=MAX('Table'[Date].[Year]) ))
    var _months=CALCULATE(DISTINCTCOUNT('Table'[Date].[Month]),FILTER(ALLSELECTED('Table'),'Table'[Date].[Year]=MAX('Table'[Date].[Year])))
    RETURN DIVIDE(_sales,_months,0)

    Then the result is as follows.

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

     

     

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi MarshalSK ,

     

    We can create a measure.

    avg = 
    var _sales=CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Table'),'Table'[Date].[Year]=MAX('Table'[Date].[Year]) ))
    var _months=CALCULATE(DISTINCTCOUNT('Table'[Date].[Month]),FILTER(ALLSELECTED('Table'),'Table'[Date].[Year]=MAX('Table'[Date].[Year])))
    RETURN DIVIDE(_sales,_months,0)

    Then the result is as follows.

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

     

     

  • Daniel29195's avatar
    Daniel29195
    Community Champion

    MarshalSK 

    calculate (
    
    sum(tblname[sales_col_name]),
    
    removefilters( tbl_name[month_col_name], tbl_name[month_nb_col_name])
    
    )
    
    / 12 

     

     

     

     

    If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution !
    It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠@

     

    • MarshalSK's avatar
      MarshalSK
      Resolver I

      Thanks for the reply. Expecting dynamic solution, meaning 12 needs to be dynamic. 

      considering below scenario
      1. month slicer

      2. if any month doesn't have data