Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

calculate average for all month dates

Hi,

when I click any month on slicer I want to calculate avg of every month sales,(for ex: June I have 5 days so I need avg of

{sum(5 days)/count(5 days)} 

Channel Partners = (132482.64+0+18540.00+0+30216.00)/5 = 36247.728

 

Avg.JPG

 

regards,

Naveen

2 ACCEPTED SOLUTIONS

@Anonymous , ah, you are considering distinct dates across different segments. Try

measure =
divide(sum(Table[sales]),calculate(distinctcount(Table[date]),allexcept(table,table[segment])))

measure =
divide(sum(Table[sales]),calculate(distinctcount(Table[date]),alle(table[segment])))

 

View solution in original post

Hi @Anonymous ,

 

You may create measure like DAX below.

 

 

Channel Partners=

Var _TotalSum= CALCULATE(SUM(financials[Sales]), ALLSELECTED(financials))

Var _TotalCount= CALCULATE(DISTINCTCOUNT(financials[Date]), ALLSELECTED(financials))

Return

DIVIDE(_TotalSum, _TotalCount, 0)

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , Try like

measure =
divide(sum(Table[sales]),distinctcount(Table[date]))

 

or

Measure =
var _max = datediff(minx(allselected('Table'),'Table'[Date]),maxx(allselected('Table'),'Table'[Date]),day)\
return
divide(sum('Table'[sales]),_max)

Anonymous
Not applicable

hi @amitchandak ,

thanks for quick replay,

 

Avg1.JPG

here, blank value dates column are not taking this measure -->(132482.64+18540.00+30216)/3 = 60412.88 

i want like this value --> (132482.64+0+18540.00+0+30216)/5 = 36247.728

@Anonymous , Try 2nd one this option

Measure =
divide(sum('Table'[sales]),datediff(eomonth(min('Table'[Date]),-1)+1,max('Table'[Date]),day))

 

or

Measure =
divide(sum('Table'[sales]),datediff(min('Table'[Date]),max('Table'[Date]),day))

Anonymous
Not applicable

Hi @amitchandak 

Ex:- (132482.64+0+18540.00+0+30216)/5 = 36247.728

the measure will be showing the wrong average - 15103

Avg2.JPG

Hi @Anonymous ,

 

You may create measure like DAX below.

 

 

Channel Partners=

Var _TotalSum= CALCULATE(SUM(financials[Sales]), ALLSELECTED(financials))

Var _TotalCount= CALCULATE(DISTINCTCOUNT(financials[Date]), ALLSELECTED(financials))

Return

DIVIDE(_TotalSum, _TotalCount, 0)

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

@Anonymous , ah, you are considering distinct dates across different segments. Try

measure =
divide(sum(Table[sales]),calculate(distinctcount(Table[date]),allexcept(table,table[segment])))

measure =
divide(sum(Table[sales]),calculate(distinctcount(Table[date]),alle(table[segment])))

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.