Forum Discussion
Dennis_Pedersen
7 years agoHelper I
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...
- Anonymous7 years ago
[Avg Prod Days] := AVERAGEX( VALUES( Orders[Vendor Number] ), [Avg Prod Days for Vendor] ) -- This works OK even if one vender is visible.
Best
Darek
Anonymous
7 years agoNot 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.
- Dennis_Pedersen7 years agoHelper I
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 ?
- Anonymous7 years agoNot 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
- Dennis_Pedersen7 years agoHelper I
thanks a lot