How to calculate the weighted average of different fields in a cube data source such as Multidimensional Expressions (MDX)
Follow the steps below to calculate the weighted average of Internet Freight Cost and Internet Order Count by using a calculated member.
SUM(
[product categories].currentmember.children, [internet order count] * [internet freight cost])
/ SUM(
[product categories].currentmember.children, [internet order count]
)
The following example guides you through creating a MDX statement across both the product and customer geography dimensions. This complex weighted average example tells Tableau to get the weighted average of Internet Sales Amount, across each combination of Subcategory and Country, for their respective descendants.
Sum(
CrossJoin(
Descendants ([Product].[Product Categories].CurrentMember,
[Product].[Product Categories].[Subcategory], SELF),
Descendants ([Customer].[Customer Geography].CurrentMember,
[Customer].[Customer Geography].[Country], SELF)
)
,([Measures].[Internet Sales Amount] * [Measures].[Internet Order Quantity])
) / [Measures].[Internet Order Quantity]
001458065
58 KB

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.