Forum Discussion
Return max row count
- 4 years agoexpected result: =VAR amounttotal =CALCULATE (SUM ( 'Table'[Amount] ),ALLEXCEPT ( 'Table', 'Table'[Month], 'Table'[Cost Centre] ))VAR maxperiodnumber =CALCULATE (COUNTROWS('Table'),ALLEXCEPT ( 'Table', 'Table'[Month], 'Table'[Cost Centre] ))RETURNIF ( HASONEVALUE ( 'Table'[Month] ), DIVIDE ( amounttotal, maxperiodnumber ) )
Anonymous You can use AVERAGEX for this:
AVERAGEX(VALUES(DimDate[Month]), [Measure])
Hi AllisonKennedy ,
Thanks for that! I did try that but it's not giving me the right output.
Essentially, within a month, we have varying numbers of pay periods. So for Sept, we have 3 whereas in August, we only had 2. So we capture data each pay period but i need to essentially sum up values for that month and then determine how many pay periods there were and divide by that to average it.
When i use the DAX above, i'm not getting the average for some reason 😞
- AllisonKennedy4 years agoCommunity Champion
Anonymous Glad you solved it - here's a post on Averages that you may find helpful??? https://excelwithallison.blogspot.com/2020/09/what-does-average-mean.html
Basically, if you want to average over number of pay periods, then that needs to be the first argument in your AVERAGEX function:
Measure = AVERAGEX( Values( Table[PayPeriod] ) , [Measure to Average] )
Hope that helps you in future!