Forum Discussion
Calculate an average from a Sum by Month
- 10 years ago
Hi Mertsch,
I have tested it on my local environment, you can add calculated column to display the month name using the DAX below
Month = MONTH(MonthAverage[Date])And then create a measure
MeasureAverage = SUM(MonthAverage[Total])/DISTINCTCOUNT(MonthAverage[Month])Regards,
Charlie Liao
edit: sorry i explane it wrong....
what i need is:
the final average:
01/2016 = Sum 160
02/2016 = Sum 120
average: 140
Looks like you want to get the average by Summing the amount and dividing it by the number of months/distinct dates rather than dividing by the number of rows.
This might help, write following DAX measures:
Amount=SUM([Values])
NumOfDistinctDates=DISTINCTCOUNT([Date])
Avg=DIVIDE([Amount],[NumOfDistinctDates])
nikil
Check out the Chicagoland Power BI User Group
- mertsch10 years agoFrequent Visitor
well it wokrs for the full tabel but if i used filters it dont work for it.
( 140 is correct for all data )
But after using Filters it will be still 140. it need to be 60 in that case
There must be a other way to have it more flexible with using filters
The data need to be calculated acording to the used filters and visual in front end.
May it works with GROUPBY Month Dates?! But i dont get the DAX work
= GROUPBY (Tabelle1;Tabelle1[Month];“TEST2”;SUM(CURRENTGROUP();Tabelle1[Total]))
- v-caliao-msft10 years ago
Microsoft Employee
Hi Mertsch,
I have tested it on my local environment, you can add calculated column to display the month name using the DAX below
Month = MONTH(MonthAverage[Date])And then create a measure
MeasureAverage = SUM(MonthAverage[Total])/DISTINCTCOUNT(MonthAverage[Month])Regards,
Charlie Liao
- Kinsey9 years ago
Advocate III
This does not work if the data covers a period longer than a year as multiples will appear over multiple years, is there another way?
- vikrammankar7 years agoFrequent Visitor
Simple & Effective solution. Cheers
- Anonymous7 years agoNot applicable
Hey,
I have one more question here, i ahave one Power Bi template, which has Hours by month Operating Group wise.
Cureently in Power Bi i am using Matrx visual for this and i have the data from February 2018 to December 2018, i .e for 10 months.
But when i used the formual
Average Hours = SUM('MC Payroll and Hours'[Hours]) / DISTINCTCOUNT('Dates'[Month].[Month])ForDISTINCTCOUNT('Dates'[Month].[Month]) it was taking months count as 12 not 10, is there any way that i can write code for taking only 10 months.(of visual has 10 months data, months count should come to 10, if visual has data for 8 months, count should come to 8.)My Financial Year is September to Aug.thanks.