Forum Discussion
Year over Year in Line and Column Chart
- 6 years ago
Hi harrisonearl ,
I've create this file as an example: Download PBIX
If you have more than 1 value for the same item in x-axis, the calculation gets all the values for that item...that's why you are getting the wrong value.
Perhaps it's better to have a chart with dates on a-axis instead of month...so you can see it by the time..or a chart without passenger numbers and just the values of the YoY....
I realized that column values handles it differently from Line values...
I hope it helps or someone can bring a better solution for it.
Ricardo
Hi harrisonearl ,
Do you have a date table ? Are you using the function SAMEPERIODLASTYEAR ?
https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax
Ricardo
camargos88 My data only has one line for each month, so it doesn't seem to want to let me use a date table. My YoY caluclation is the built in one, SAMEPERIODLASTYEAR doesn't seem to work since the dates aren't continous since I only have one for each month.
Passengers YoY% =
IF(
ISFILTERED('Sheet2'[Year and Month]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __PREV_YEAR =
CALCULATE(
SUM('Sheet2'[Passengers]),
DATEADD('Sheet2'[Year and Month].[Date], -1, YEAR)
)
RETURN
DIVIDE(SUM('Sheet2'[Passengers]) - __PREV_YEAR, __PREV_YEAR)
)
- camargos886 years ago
Community Champion
- harrisonearl6 years agoFrequent Visitor
camargos88 Here's the data I'm working with, nothing too complicated.
Date Passengers 1/1/2018 68811 2/1/2018 67205 3/1/2018 81203 4/1/2018 81989 5/1/2018 97435 6/1/2018 102286 7/1/2018 100199 8/1/2018 91499 9/1/2018 87045 10/1/2018 102181 11/1/2018 93455 12/1/2018 90185 1/1/2019 76377 2/1/2019 74317 3/1/2019 98502 4/1/2019 91783 5/1/2019 113905 6/1/2019 119654 7/1/2019 123378 8/1/2019 110506 9/1/2019 102927 10/1/2019 116707 11/1/2019 101891 12/1/2019 106283 1/1/2020 89461 - Anonymous6 years agoNot applicable
What you can do is... attached in the file. And it's not true you cannot use a proper calendar and time-intel functions. You can but you have to know how. The model in the file shows you the correct way.
Best
D