Forum Discussion
Chart shows max one year back from slicer`s choice
- Anonymous4 years ago
Hi aaldo_666 ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. Assume that you have a year quarter dimension table as below, then you can create a measure as below:
Measure = VAR _selyear = SELECTEDVALUE ( 'YearQuarter'[Year] ) VAR _selquarter = SELECTEDVALUE ( 'YearQuarter'[Quarter] ) VAR _qnum = VALUE ( RIGHT ( _selquarter, 1 ) ) RETURN CALCULATE ( SUM ( 'Table'[Sales amount] ), FILTER ( 'Table', IF ( _qnum = 4, 'Table'[Year] = _selyear && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= 1 && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= 4, ( 'Table'[Year] = _selyear && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= 1 && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= _qnum ) || ( 'Table'[Year] = _selyear - 1 && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= _qnum + 1 && VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= 4 ) ) ) )If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi aaldo_666 ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. Assume that you have a year quarter dimension table as below, then you can create a measure as below:
Measure =
VAR _selyear =
SELECTEDVALUE ( 'YearQuarter'[Year] )
VAR _selquarter =
SELECTEDVALUE ( 'YearQuarter'[Quarter] )
VAR _qnum =
VALUE ( RIGHT ( _selquarter, 1 ) )
RETURN
CALCULATE (
SUM ( 'Table'[Sales amount] ),
FILTER (
'Table',
IF (
_qnum = 4,
'Table'[Year] = _selyear
&& VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= 1
&& VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= 4,
(
'Table'[Year] = _selyear
&& VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= 1
&& VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= _qnum
)
|| (
'Table'[Year] = _selyear - 1
&& VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) >= _qnum + 1
&& VALUE ( RIGHT ( 'Table'[Quarter], 1 ) ) <= 4
)
)
)
)
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards