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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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