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 September 15. Request your voucher.

Reply
Rudd_ThreeTrees
Frequent Visitor

Calculate average of measure based on id

Dear wrinkle brains

I have the following dim table:

Supplier:

Supplier_IDSupplier_Name
s1example_1
s2example_2

and the following two fact tables:

Purchase:

Purchase_IDOrder_DatePurchase_Supplier
p118.3.2023s1
p219.3.2023s2
p320.3.2023s1

Supply:

Purchase_IDSupply_Date
p124.3.2023
p227.3.2023
p328.3.2023

 

I added the following measure to my measure table:

TimeDiff = DATEDIFF(max('Purchase'[Order_Date]),max(Supply[Supply_Date]),DAY)

 

Now i want to show the average of the TimeDiff for every supplier (and filter the visual based on the supplier).
Every hint or example very appreciated!

Cheers!

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Rudd_ThreeTrees 

 

You can try the following methods.

Measure:

Average = 
Var _table = SUMMARIZE(Purchase,Purchase[Purchase_ID],Purchase[Purchase_Supplier],"Timediff",[TimeDiff])
Return
AVERAGEX(FILTER(_table,[Purchase_Supplier]=MAX(Supplier[Supplier_ID])),[Timediff])

vzhangti_0-1690341295177.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @Rudd_ThreeTrees 

 

You can try the following methods.

Measure:

Average = 
Var _table = SUMMARIZE(Purchase,Purchase[Purchase_ID],Purchase[Purchase_Supplier],"Timediff",[TimeDiff])
Return
AVERAGEX(FILTER(_table,[Purchase_Supplier]=MAX(Supplier[Supplier_ID])),[Timediff])

vzhangti_0-1690341295177.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors