Forum Discussion
Blank Year over Year Column
- Anonymous9 years ago
Make sure your column Shipments[Date] is of type date value!
If you don't want to work with a separate date table and relate that table to your fact table you can still make it work by doing this instead:
Use Shipments[Date] directly in your visualization instead of using the calculations YEAR(..) and MONTH(...)
Power BI will create a date hierarchy for you automatically.
Change the meassure for RevLastYear to: CALCULATE([SumRevenue],DATEADD(Shipments[Date].[Date],-1,YEAR))
That should give you what you are looking for.
Br,
Magnus
- Anonymous9 years ago
Hi Anonymous,
You can use below formula to get the previous years' total.
Pervious Year Total =
var currDate=MAX([Date])
return
SUMX(FILTER(ALL(Shipments),Shipments[Date]>=DATE(YEAR(currDate)-1,1,1)&&Shipments[Date]<=DATE(YEAR(currDate)-1,12,31)&&MONTH([Date])=MONTH(currDate)),[Total Revenue])Pervious Year(Month/Year) =
SUMX(FILTER(ALL(Shipments),Shipments[Date]>=DATE(MAX([Year])-1,1,1)&&Shipments[Date]<=DATE(MAX([Year])-1,12,31)&&[Month]=MAX([Month])),[Total Revenue])Result:
Regards,
Xiaoxin Sheng
Hi Anonymous,
You can use below formula to get the previous years' total.
Pervious Year Total =
var currDate=MAX([Date])
return
SUMX(FILTER(ALL(Shipments),Shipments[Date]>=DATE(YEAR(currDate)-1,1,1)&&Shipments[Date]<=DATE(YEAR(currDate)-1,12,31)&&MONTH([Date])=MONTH(currDate)),[Total Revenue])
Pervious Year(Month/Year) =
SUMX(FILTER(ALL(Shipments),Shipments[Date]>=DATE(MAX([Year])-1,1,1)&&Shipments[Date]<=DATE(MAX([Year])-1,12,31)&&[Month]=MAX([Month])),[Total Revenue])
Result:
Regards,
Xiaoxin Sheng
- Thiyags9 years agoHelper II
Anonymous
Did you use SAMEPERIODLASTYEAR function?
CALCULATE(SUM(Shipments[Total Revenue]),SAMEPERIODLASTYEAR(Shipments[Date ].[Date]))