Sub topic 12
Allocating values with weight columns
This chapter assumes you have built a bridge table with unique keys and wired it to two dimensions. It also assumes you can write SUMX, CALCULATE, and TREATAS measures. If a shared account links to several customers, the plain bridge counts the full amount for each customer. This chapter shows how to split the amount instead.
Why a weight column
Suppose account A100 is shared by two customers. A report by customer shows the full A100 amount under both of them. The grand total is correct, but the customer rows add up to more than the total.
A weight column fixes this. Each bridge row stores the share of the account that belongs to that customer. For every account, the weights add up to 1.
| AccountID | CustomerID | Weight |
|---|---|---|
| A100 | C1 | 0.6 |
| A100 | C2 | 0.4 |
| A200 | C1 | 1.0 |
The weight is a business rule, such as ownership percentage or an agreed split. It does not come from the model. You load it from a source system or maintain it in a table of its own.
The allocation measure
The measure visits each bridge row that the Customer filter leaves visible. For each row, it takes the amount for that row's account and multiplies it by the row's weight.
Total Amount = SUM ( Transactions[Amount] )
Allocated Amount =
SUMX (
AccountBridge,
AccountBridge[Weight]
* CALCULATE (
[Total Amount],
TREATAS ( { AccountBridge[AccountID] }, Transactions[AccountID] )
)
)TREATAS filters Transactions[AccountID] without needing bidirectional filtering on the bridge. The curly braces build a one-column table from the current row's AccountID.
With the sample weights, C1 gets 60 percent of A100 plus all of A200. C2 gets 40 percent of A100.
Check that the weights add up
Allocation only works if the weights for each account sum to 1. If they sum to 1.2, you inflate the total. If they sum to 0.8, you lose value. Test the result against the grand total:
Allocation Check =
VAR GrandTotal = CALCULATE ( [Total Amount], ALL ( Customers ) )
VAR VisibleSum = SUMX ( VALUES ( Customers[CustomerID] ), [Allocated Amount] )
RETURN
VisibleSum - GrandTotalThis is the same check used for the unweighted bridge. With correct weights it returns 0 when no filter hides customers. A non-zero value points to one of two causes:
- Some account has weights that do not sum to 1.
- Some transactions use an
AccountIDthat has no bridge row, so no customer receives them.
Common errors
- Weights on the wrong table. A weight stored on
CustomersorAccountscannot describe a per-pair share. It belongs on the bridge, one value per pair. - Duplicate bridge rows. A repeated pair counts its weight twice. Build the bridge with
DISTINCT, as in the earlier chapter. - Multiplying the weight after a total. Multiplying
[Total Amount]bySUM ( AccountBridge[Weight] )is wrong. That uses the sum of all weights, not the weight for each account. The multiplication must happen per bridge row insideSUMX. - Reading the grand total of a filtered visual. If a slicer hides some customers, the visible rows add up to less than the total. This is expected and is not a weight error.
Exercise
Account B500 has total amount 200 and three bridge rows with weights 0.5 (C1), 0.3 (C2), and 0.3 (C3). What does the grand total of the allocated amounts equal, and what does that tell you?
Show answer
The weights sum to 1.1, so the allocated amounts for B500 add up to 220. That is 20 more than the real amount. Allocation Check returns 20 for this account, which shows that the weights are wrong. Fix the weights so they sum to 1, for example 0.5, 0.3, and 0.2.