To show Sales and YoY Sales in Power BI, follow these steps:
Step 1: Import the Dataset
- Open Power BI Desktop.
- Click Home → Get Data → Text/CSV.
- 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.
- Go to Modeling → New Table.
- 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]) )
- Mark this as a Date Table:
- Click the DateTable in the Fields pane.
- Go to Table Tools → Mark as Date Table → Select 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
- Add a Line Chart or Table.
- Drag DateTable[Date] to the X-axis (for Line Chart) or Columns (for Table).
- Drag Total Sales and YoY Sales into Values.
- 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.