Forum Discussion
Freight Cost per Unit - Invoice Cost Allocation
- Anonymous2 years ago
Hi RAQuest
You can create a new calculated column in your data table to calculate the freight cost per unit for each row. You can use the following DAX formula:
DAX Freight Cost per Unit = [FreightAmt] / SUMX(FILTER('YourTableName', 'YourTableName'[InvoiceNo] = EARLIER('YourTableName'[InvoiceNo])), 'YourTableName'[QuantityShipped])Replace 'YourTableName' with the actual name of your table.
Here's what this formula does:
- `FILTER` function is used to create a table that contains only the rows with the same `InvoiceNo`.
- `SUMX` function iterates over this filtered table and sums up the `QuantityShipped` for the invoice.
- The total freight amount (`FreightAmt`) for the invoice is then divided by this sum to get the freight cost per unit.
Once you have created the calculated column, you can use it in your reports to analyze the data. You can format it in Column tools ribbon.
Best regards,
Jing
Hi RAQuest
You can create a new calculated column in your data table to calculate the freight cost per unit for each row. You can use the following DAX formula:
DAX Freight Cost per Unit = [FreightAmt] / SUMX(FILTER('YourTableName', 'YourTableName'[InvoiceNo] = EARLIER('YourTableName'[InvoiceNo])), 'YourTableName'[QuantityShipped])Replace 'YourTableName' with the actual name of your table.
Here's what this formula does:
- `FILTER` function is used to create a table that contains only the rows with the same `InvoiceNo`.
- `SUMX` function iterates over this filtered table and sums up the `QuantityShipped` for the invoice.
- The total freight amount (`FreightAmt`) for the invoice is then divided by this sum to get the freight cost per unit.
Once you have created the calculated column, you can use it in your reports to analyze the data. You can format it in Column tools ribbon.
Best regards,
Jing
- RAQuest2 years agoNew Member
Jing - thank you so much for sharing your wisdom. More so, your explain of how and why your measure worked!