The following steps describe how to create a measure to calculate the profit of Power BI:
Open Power BI Desktop and load your data.
In the Fields pane, locate your datasheet.
Right-click the name of the data table and select New Measure.
In the New Measure dialog box, give the measure a name, such as Profit.
Enter the following DAX formula in the Formula column to calculate the profit:
DAX profit = SUM([ sales price ])-SUM([ cost price])
This formula will calculate the sum of the "sales price" of all lines and subtract this value from the sum of the "purchase price cost" to obtain the total profit.
Click OK to create the measure.
Now you have a measure called Profit, which can be used in reports and dashboards.
To display profits in a report, you can create a card chart or other visual element and add profit measures to the value area. After that, you can use the filtering function of the report to filter the data and view the filtered profits in real time.
Please note that the above formula assumes that "Sales Price" and "Purchase Cost" are both numeric columns and located in the same data table. If your data structures are different, adjust the column names and table names accordingly.
In addition, if you have multiple RELATED tables in your data model, and you want to calculate profits according to a specific relationship, you may need to use related functions in DAX (such as related or RELATEDTABLE) to ensure that the sum is calculated correctly.