Categories: Power BI
Tags:

To show Sales and YoY Sales in Power BI, follow these steps:

Step 1: Import the Dataset

  1. Open Power BI Desktop.
  2. Click HomeGet DataText/CSV.
  3. Select the CSV file and click Load.

Step 2: Create a Date Table

Power BI’s time intelligence functions work best with a dedicated Date Table.

  1. Go to ModelingNew Table.
  2. Enter this DAX formula to create a Date Table: DateTable = ADDCOLUMNS ( CALENDAR (DATE(2022,1,1), DATE(2024,12,31)), "Year", YEAR([Date]), "Month", FORMAT([Date], "MMM"), "MonthNumber", MONTH([Date]) )
  3. Mark this as a Date Table:
    • Click the DateTable in the Fields pane.
    • Go to Table ToolsMark as Date TableSelect Date Column.

Step 3: Create Measures for Sales and YoY Sales

Now, create two DAX measures:

1️⃣ Total Sales

Total Sales = SUM(SalesData[Sales])

2️⃣ YoY Sales Growth

YoY Sales = 
CALCULATE(
[Total Sales],
SAMEPERIODLASTYEAR('DateTable'[Date])
)

Step 4: Create a Visual

  1. Add a Line Chart or Table.
  2. Drag DateTable[Date] to the X-axis (for Line Chart) or Columns (for Table).
  3. Drag Total Sales and YoY Sales into Values.
  4. Format the chart and set the date hierarchy.

Step 5: Bonus – Add YoY % Change

To calculate YoY % Growth, add this measure:

YoY % Change = 
DIVIDE([Total Sales] - [YoY Sales], [YoY Sales], 0)

Use a KPI card or Bar Chart to display YoY % Growth.

Note:

Verify the Relationship Between Tables

  • Go to Model View.
  • Ensure SalesData[Date] is related to DateTable[Date] (many-to-one).
  • If missing, create this relationship.

Final Result

Sales and YoY Sales will be shown on a visual.
✅ Use a Line Chart to see trends over time.
✅ Use a Matrix/Table to compare values side by side.