I’m struggling with a previous YTD calculation. If I place the measures in a table to show results by month or totals by year (i.e. first column in the table is a date field), it provides the full monthly or full yearly totals. And when I try to use the formula to compare YOY progress for salespeople or items, it shows the PYTD as the entire year and not the same period from last year.
Here are my measures.
Total Sales =
CALCULATE(
SUMX(Billing,Billing[Ship_Dollars]),
USERELATIONSHIP(‘Dates’[Date],Billing[Ship_Date]))
Sales Year to Date =
CALCULATE(
[Total Sales] ,
DATESYTD( Dates[Date] ) )
I’ve tried two separate measures to get last year’s YTD numbers.
Sales Year to Date LY =
CALCULATE(
[Sales Year to Date],
SAMEPERIODLASTYEAR( Dates[Date] ))
Sales YTD LY =
CALCULATE(
[Sales Year to Date],
DATEADD( Dates[Date],-1,YEAR ))
I’ve also explored these options, with the same results.
Sales Period This Year =
VAR LastSalesDate = MAXX(All(Billing[Ship_Date]), Billing[Ship_Date])
VAR SalesThisYear = TOTALYTD([Total Sales], Dates[Date])
RETURN
If (MIN(Dates[Date])<= LastSalesDate, SalesThisYear, Blank() )
Sales Period Last Year =
IF(LASTDATE(Dates[Date])<=TODAY(),
CALCULATE([Sales Period This Year],
SAMEPERIODLASTYEAR(Dates[Date])),
BLANK()
)
Another consideration - I use a relative date filter on the report page to show items when the value is in this year.
I’m not able to upload a PBIX file since it contains sensitive company data. Any help is appreciated.