How to Add Measure in Power BI
To add a measure in Power BI, you can follow these steps:
- Open your Power BI Desktop application.
- Connect to your data source by selecting the “Get Data” option from the Home tab.
- Select your desired data source from the available options.
- Once your data is loaded into the Power BI Desktop, navigate to the “Report” view.
- Locate the “Fields” pane on the right side of the screen. This pane displays all the available fields from your data source.
- Right-click on the table or dataset where you want to add the measure.
- Select the “New Measure” option from the context menu.
- A formula bar will appear at the top of the screen, allowing you to enter your custom measure calculation.
- Enter a name for your measure in the formula bar. For example, if you want to create a measure to calculate total sales, you can name it “Total Sales”.
- Write your measure formula in the formula bar. For instance, if you have a “Sales” column and you want to calculate the sum of all sales, you can enter the formula as “=SUM([Sales])”.
- Press Enter to save the measure.
- You will now see the newly created measure under the respective table or dataset in the “Fields” pane.
- Drag and drop the measure onto the Canvas to visualize it in a visual or create custom visualizations using the measure.
Here’s an example to illustrate the process:
Let’s say you have a dataset containing a table called “Sales” with columns “Product”, “Quantity”, and “Price”. To create a measure to calculate the total sales amount, you can follow the steps mentioned above:
- Right-click on the “Sales” table in the Fields pane.
- Select “New Measure”.
- In the formula bar, enter “=SUMX(Sales, [Quantity] * [Price])”
- Press Enter to save the measure.
- The new measure, named “Total Sales Amount”, will now be available in the Fields pane under the “Sales” table.
- Drag and drop the “Total Sales Amount” measure onto the Canvas to visualize it in a visual or create custom visualizations using the measure.
By adding measures in Power BI, you can perform complex calculations, aggregations, and create insightful visualizations based on your specific requirements.