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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply

Average for some rows

Hi 

 

Could you please help with a Dax Formula for calculating average production days?

In this case, I need the result 90 for vendor 7 and 70 for vendor 5. (2 orders each vendor). Number of lines/items is not relevant

 

The fact table:

Vendor number:         Order number:               Item Number:             Production days:

7                                  100                                50                                80

7                                  100                                51                                80

7                                  188                                50                                100

5                                   20                                 50                                 60

5                                   20                                 51                                 60

5                                   25                                 50                                 80

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

[Avg Prod Days] :=
AVERAGEX(
	VALUES( Orders[Vendor Number] ),
	[Avg Prod Days for Vendor]
)
-- This works OK even if one vender is visible.

Best

Darek

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

[Avg Prod Days for Vendor] :=
var __vendor = VALUES( Orders[Vendor Number] )
var __oneVendorVisible = HASONEFILTER( Orders[Vendor Number] )
return
	if( __oneVendorVisible,
		AVERAGEX(
			SUMMARIZE(
				Orders,
				Orders[Order Number],
				Orders[Production days]
			),
			Orders[Production days]
		)
	)
	
-- The assumption is that
-- each order number has the same production days
-- for each of its item numbers. If this is not
-- true the code will return wrong results. But this
-- assumption seems reasonable based on the sample
-- data supplied.

Hi Darlove

 

Thanks a lot. That works just fine.

That gives the correct figure for each vendor. Is there any way to calculate the correct average for alle vendors ?

Anonymous
Not applicable

[Avg Prod Days] :=
AVERAGEX(
	VALUES( Orders[Vendor Number] ),
	[Avg Prod Days for Vendor]
)
-- This works OK even if one vender is visible.

Best

Darek

thanks a lot

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.