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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Mars3442
Helper I
Helper I

Average based on date slicer

Hi all,

I have created a table like this

Sales table

Mars3442_0-1697448791843.png

I created a date slicer 

And I want to create a card that would show the average based on the selected period

So,

When I select Jan, Feb, and March in the slicer

Sales Jan = 100 + 200 + 500 = 800

Sales Feb = 150 + 200 + 400 = 750

Sales March = 300 + 160 + 450 = 910

I want the card showing the average sales for 3 months = (800+750+910)/3 = 820

 

When I select Jan, Feb, and March in the slicer

Sales Jan = 100 + 200 + 500 = 800

Sales Feb = 150 + 200 + 400 = 750

Sales March = 300 + 160 + 450 = 910

Sales April= 220+ 210 + 500 = 930

I want the card showing the average sales for 4 months = (800+750+910+930)/4 = 847,5

 

Please help me to solve this problem

Thank you..

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

hi, @Mars3442 

 

Try below code 

adjust your table name

result =
var a = SUM('Table'[sales])
var b =CALCULATE(DISTINCTCOUNT('Table'[date]))
return DIVIDE(a,b)
 
Dangar332_0-1697450139072.pngDangar332_1-1697450159873.png

 

View solution in original post

3 REPLIES 3
Dangar332
Super User
Super User

hi, @Mars3442 

 

Try below code 

adjust your table name

result =
var a = SUM('Table'[sales])
var b =CALCULATE(DISTINCTCOUNT('Table'[date]))
return DIVIDE(a,b)
 
Dangar332_0-1697450139072.pngDangar332_1-1697450159873.png

 

Hi, @Dangar332 

Thanks a ton! Works perfectly!

Hi, @Mars3442 

 

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.