How To Calculate Previous Year Sales In Power Bi

Calculating Previous Year Sales in Power BI

Power BI provides various functionalities to calculate previous year sales. One popular method involves using DAX formulas and measures to achieve this. Let’s go through the steps and provide an example using sample sales data.

Step 1: Preparing the Data

Assuming you have a dataset with sales data containing at least two columns: “Date” and “Sales”. Make sure the “Date” column is recognized as a date or use the Power Query Editor to convert it into a date format if necessary.

Step 2: Creating a New Measure

In Power BI, navigate to the “Modeling” tab and click on “New Measure”. Enter a name for the measure, such as “Previous Year Sales”.

Now, you can use the following DAX formula to calculate the previous year sales:


    Previous Year Sales =
    CALCULATE(
        SUM(Sales[Sales]),
        SAMEPERIODLASTYEAR('Calendar'[Date])
    )
  

Step 3: Adding the Measure to a Visual

To see the result of the previous year sales calculation, you can add a visual, such as a table or a card, to your report or dashboard. Drag and drop the “Previous Year Sales” measure onto the visual.

Example

Let’s assume we have a sales dataset with the following records:

Date Sales
01-01-2020 100
02-01-2020 150
01-01-2021 200
02-01-2021 250

After creating the “Previous Year Sales” measure as mentioned in Step 2, when you add it to a visual, you will see:

Visual Previous Year Sales
Table 250
Card 250

This means that the previous year sales for the selected period is 250.

By following the above steps and using the provided DAX formula, you can calculate the previous year sales in Power BI for your own sales data.

Leave a comment