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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Calculate average based on Date Table

Hi,
Please advise on how to solve this.

I have 3 Tables in my model, 1 Date Table, 1 Sales Table, 1 Product Table 

I am having problem calculating average of a Product sold based on the Date Table instead of averaging over the dates in Product Table. I have a one to many relationship propagating from Date Table to Sales and then to Product Table. When i put them together in a table visual, Sales Id, Avg Sales, Product, Average Product Amount ,how can i get the average amount of product to take into account those with 0 Sales

Date Table

DateMonth
6/23/2020June
6/22/2020June
6/21/2020June

Sales Table

SalesIdDateSales Amount
16/21/202010
16/22/202010
16/23/202020
26/21/20200
26/22/20200
26/23/202010

 

Product Table

Sales IdDateProductAmount
16/21/2020B10
16/22/2020B10
16/23/2020C20
26/23/2020A10

 


Desired Result: 

SalesIdAvg Sales AmtProductAvg Product Amt
113.3B(10+10)/3=6.67
113.3C20/3=6.67
23.3A10/3=3.33



Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below to get the average of product amount based on dates:

Avg Product Amt = 
VAR _sumproAmount =
    CALCULATE (
        SUM ( 'Product'[Amount] ),
        ALLEXCEPT ( 'Product', 'Product'[Product] )
    )
VAR _countofDates =
    CALCULATE ( DISTINCTCOUNT ( 'Date'[Date] ) )
RETURN
    DIVIDE ( _sumproAmount, _countofDates )

average.JPG

Best Regards

Rena

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , Create a common table sales Id

 

Sales Id = distinct(union(all(Sales[SalesId]),all(Product[SalesId])))

 

Join sales and product with date and sales id, Do not join sales and product. Now you can have data together

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,
Thanks for the reply
I stil don't quite get it, in my current model, my merged the SalesID and Date Column to be the primary key that connects to the Product Table. I also need other column information from the Product Table eg: serial number from the Product Table to be matched to the Sales ID.

Thanks for your help.

Anonymous
Not applicable

Hi @Anonymous ,

Could you please just provide your desired result? Whether the below screen shot is what you want to get?

expect result.JPG

Best Regards

Rena

Anonymous
Not applicable

Hi @Anonymous ,
I have already updated the desired result in the post. Basically, i would like the average over the Date from the Date Table instead of the number of entries in the Product Table. Is that doable?

Thanks

Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below to get the average of product amount based on dates:

Avg Product Amt = 
VAR _sumproAmount =
    CALCULATE (
        SUM ( 'Product'[Amount] ),
        ALLEXCEPT ( 'Product', 'Product'[Product] )
    )
VAR _countofDates =
    CALCULATE ( DISTINCTCOUNT ( 'Date'[Date] ) )
RETURN
    DIVIDE ( _sumproAmount, _countofDates )

average.JPG

Best Regards

Rena

@Anonymous ,

Sum(Product[Product Amount]) +0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors