Forum Discussion
year over year problem
- 5 years ago
Hi, rikisax
According to your description and sample picture, you want to get the Plants previous year based on the time period selected in the Slicer. I created some data based on your data and achieve this, you can take a look and find if it’s useful:
This is my test data:
- Create a Calendar table and do not give them the relationship, because the value of [Plants previous year] will be filtered if the relationship is given:
Calendar = CALENDARAUTO()- Create two measures:
Plants perivous year = var _mindate=MIN('Calendar'[Date]) var _maxdate=MAX('Calendar'[Date]) return CALCULATE(SUM(BI_SpecieSettimaneOV[Plants]), FILTER('BI_SpecieSettimaneOV', [Date]>=DATE(YEAR(_mindate)-1,MONTH(_mindate),DAY(_mindate))&& [Date]<=DATE(YEAR(_maxdate)-1,MONTH(_maxdate),DAY(_maxdate))))Plants this year = var _mindate=MIN('Calendar'[Date]) var _maxdate=MAX('Calendar'[Date]) return CALCULATE(SUM(BI_SpecieSettimaneOV[Plants]), FILTER('BI_SpecieSettimaneOV', [Date]>=_mindate&&[Date]<=_maxdate))- Create a Slicer and place ‘Calendar’[Date], then a Matrix and place it like this:
And I guess this can roughly meet the requirement that you want.
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, rikisax
According to your description and sample picture, you want to get the Plants previous year based on the time period selected in the Slicer. I created some data based on your data and achieve this, you can take a look and find if it’s useful:
This is my test data:
- Create a Calendar table and do not give them the relationship, because the value of [Plants previous year] will be filtered if the relationship is given:
Calendar = CALENDARAUTO()
- Create two measures:
Plants perivous year =
var _mindate=MIN('Calendar'[Date])
var _maxdate=MAX('Calendar'[Date])
return
CALCULATE(SUM(BI_SpecieSettimaneOV[Plants]),
FILTER('BI_SpecieSettimaneOV',
[Date]>=DATE(YEAR(_mindate)-1,MONTH(_mindate),DAY(_mindate))&&
[Date]<=DATE(YEAR(_maxdate)-1,MONTH(_maxdate),DAY(_maxdate))))Plants this year =
var _mindate=MIN('Calendar'[Date])
var _maxdate=MAX('Calendar'[Date])
return
CALCULATE(SUM(BI_SpecieSettimaneOV[Plants]),
FILTER('BI_SpecieSettimaneOV',
[Date]>=_mindate&&[Date]<=_maxdate))
- Create a Slicer and place ‘Calendar’[Date], then a Matrix and place it like this:
And I guess this can roughly meet the requirement that you want.
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.