Forum Discussion
Ignore filter year selection
- 10 years ago
Alright, I think I understood you now. What you want is to show the previous year no matter what year is selected. For eg, if we are on 2016, you always want to show 2015 data, even if we select 2010 or 2012 or any other year on filter.
1) Create a measure that will show the max year available in the fact table
MaxYear=CALCULATE(MAX('Fact'[Year]), ALL('Fact'[Year]))
2) Now make the measure as you want. Instead of hardcoding 2014, you can use the measure which will always return the max year available in fact, irrespective of the filter.
test=CALCULATE(SUM('Fact'[Sales]), FILTER(ALL('Fact'[Year]), 'Fact'[Year]=[MaxYear]-1))
Is this what you want? :)
Did you try the formula I suggested?
Grow Year -1 = CALCULATE(SUM('Inscrições'[Value]);FILTER('Inscrições';not('Inscrições'[Pais]="Portugal"));FILTER(ALL('Inscrições'[Ano]); 'Inscrições'[Ano]=max('Inscrições'[Ano])-1)))
It should not give that error as you are using a filter function, and hence it should not give the error that you said. Can you try using my formula and then pasting the error?
Note how I used that formula in my model. You can see the test measure (where I used the formula I suggested to you) returning the previous year values.
It will also work if you use the Year in a filter.
Sql Jason
I guess i didn't express as well as i expected. Your formula works , but when i change the year on the slicer object, the table becomes empty. What iam trying to get independently of the year selected , is that the table remains the same ( in other words, just ignore the filter year selected) !
With no year selected
With year selected
- SqlJason10 years agoMemorable Member
Alright, I think I understood you now. What you want is to show the previous year no matter what year is selected. For eg, if we are on 2016, you always want to show 2015 data, even if we select 2010 or 2012 or any other year on filter.
1) Create a measure that will show the max year available in the fact table
MaxYear=CALCULATE(MAX('Fact'[Year]), ALL('Fact'[Year]))
2) Now make the measure as you want. Instead of hardcoding 2014, you can use the measure which will always return the max year available in fact, irrespective of the filter.
test=CALCULATE(SUM('Fact'[Sales]), FILTER(ALL('Fact'[Year]), 'Fact'[Year]=[MaxYear]-1))
Is this what you want? :)
- vani10 years agoHelper I
Jason i will try it , and if it works i'll back on you.
Thanks !
- Anonymous8 years agoNot applicable
Kudos for this answer. Been stuck on this for almost a full work day (wanting to display previous year in line graph when current year is selected), this works great. A great alternative if SAMEPERIODLASTYEAR() is not working, which will happen very often when there are gaps in your data.