Exercise - Add a calculated column and measure in Power BI Desktop using DAX
This exercise is written to use the Cronus sample company from the US version of Business Central. You might need to make adjustments to the steps if you use the sample company from your country or region.
Scenario
You've imported the item query in Power BI Desktop. The next step is to create a measure, using a DAX expression, that calculates the availability per item, based upon the inventory and the quantity on sales and purchases. This calculation can be created as a calculated column in the ItemAvailability table. Next you'll also create a measure that calculated the number of items that currently have a negative availability.
Steps
In Power BI Desktop, in the Data view, select New column under Table tools.
In the formula enter the following DAX expression:
Availability = ItemAvailability[Inventory] + ItemAvailability[QtyOnPurchOrder] - ItemAvailability[QtyOnSalesOrder]
Press Enter. The new column named Availability should be added to the table.
In Power BI Desktop, in the Data view, select New measure under Table tools.
In the formula enter the following DAX expression:
mNoOfItemsWithNegAvailability = CALCULATE(DISTINCTCOUNT(ItemAvailability[ItemNo]);ItemAvailability[Availability]<0)
Press Enter. The new measure names mNoOfItemsWithNegAvailability is now added to the data model.