I have done an experiment on iterable and non-iterable filter for row context and filter context in Power BI.
My understanding is measure has filter context while calculated column has row context
This is the Dax for measure:
UnitPrice (Sum) =
SUM(
'Sales by Store'[unit_price]
)
UnitPrice (Sumx) =
SUMX(
'Sales by Store',
'Sales by Store'[unit_price]
)
UnitPrice (CalSum) =
CALCULATE(
SUM(
'Sales by Store'[unit_price]
)
)
UnitPrice (CalSumx) =
CALCULATE(
SUMX(
'Sales by Store',
'Sales by Store'[unit_price]
)
)
The output in matrix table is display their respective unit price for each product within the same product category (Whole bean/teas):
This means measure has filter context but why we Sum and Calculate Sum does not display the same amount of total unit price of the product group for each product since both Dax function are not iterable?
For calculated column, I am using another column called Quantity Sold in Power Query.
Qty Sold_1 (Sum) =
SUM(
'Sales by Store',
'Sales by Store'[quantity_sold]
)
Qty Sold_2 (Sumx) =
SUMX(
'Sales by Store',
'Sales by Store'[quantity_sold]
)
Qty Sold_3 (CalSum) =
CALCULATE(
SUM(
'Sales by Store'[quantity_sold]
)
)
Qty Sold_4 (CalSumx) =
CALCULATE(
SUMX(
'Sales by Store',
'Sales by Store'[quantity_sold]
)
)
The output is Sum and Sumx will show the total amount for all the row while Calculate Sum and Calculate Sumx will show their respective unit price. quantity sold is the original column.
Transaction ID | quantity sold | Qty Sold_1 (Sum) | Qty Sold_2 (Sumx) | Qty Sold_3 (CalSum) | Qty Sold_4 (CalSumX) |
---|---|---|---|---|---|
131 | 1 | 6 | 6 | 1 | 1 |
192 | 2 | 6 | 6 | 1 | 1 |
460 | 3 | 6 | 6 | 1 | 1 |
Why Sumx (able to iterate by row) is not showing the respective quantity sold in row context and Calculate Sum is not showing the total quantity sold for all the row since it is not iterable by row in row context?