How to Calculate Total Year Sales Using DAX in Power BI
You can use the TOTALYTD
DAX function to calculate YTD sales.
DAX Measure:
YTD Sales = TOTALYTD(SUM(Sales[SalesAmount]), Dates[Date])
Explanation:
- TOTALYTD: Calculates the running total from the beginning of the year up to the specified date.
- SUM(Sales[SalesAmount]): Aggregates the sales amount.
- Dates[Date]: The date column from the calendar table in your dataset.
Make sure your date column is connected to a proper Date Table, and the table is marked as a Date Table in Power BI.