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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
furg442
New Member

Referring to another Table by calculating average

Hi community,

 

I have the following case:

 

Sales

DateSalesNew Column (average Temperature)
2024-01500 
2024-02300 
2024-03400 

 

Weather_data:

Datetemperature
2024-013
2024-015
2024-012
2024-023
2024-0211
2024-032
2024-033

 

The tables are connected (Column: date)

 

I want to create a new calculated Columnin table Sales, which calculates the average temperature each month. In this case, table Weather_data has multiple rows for each month and table Sales only has 1 row each month.

 

Example for first row (2024-01) in "Sales": 3+5+2 => average =>3.33

Example for second row (2024-02) in Sales: 3+11 => average => 7

Example for third row (2024-03) in Sales: 2+3 => average => 2.5

 

Expected result for the new column in table "Sales": 

DateSalesNew Column (average Temperature)
2024-015003.33
2024-023007
2024-034002.5

 

What would be the DAX function for the new calculated column?

 

Thank you!

 

Best

 

1 ACCEPTED SOLUTION
Corey_M
Resolver II
Resolver II

Based on your sample data it would be this 

Avg Temp = 
CALCULATE(
AVERAGE(Weather_data[temperature]),
FILTER(
    Weather_data,
    Weather_data[Date] = Sales[Date]
))

Corey_M_0-1717424342028.png

however this was based on the date column you provided, if you are using an actual date instead of the year-month text in Weather_data I would highly recommend adding a calendar table.

View solution in original post

1 REPLY 1
Corey_M
Resolver II
Resolver II

Based on your sample data it would be this 

Avg Temp = 
CALCULATE(
AVERAGE(Weather_data[temperature]),
FILTER(
    Weather_data,
    Weather_data[Date] = Sales[Date]
))

Corey_M_0-1717424342028.png

however this was based on the date column you provided, if you are using an actual date instead of the year-month text in Weather_data I would highly recommend adding a calendar table.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.