Forum Discussion
Display data for previous 4 quarters based on selected date in slicer
Hi, Gattinomio
You can try the following measure. If you want to achieve this effect, the relationship between the Date table and the Measure table cannot be activated, if you want to use this slicer to achieve the effect of filtering other visuals, you can use the Related, userrelationship function to activate the relationship.
previous 4 quarters flag =
VAR _startDate =
CALCULATE ( MIN ( 'Date'[Date] ) )
VAR _endDate =
CALCULATE ( MAX ( 'Date'[Date] ) )
VAR _date_diff = _endDate - _startDate
VAR _ture_endDate = _startDate + 365
VAR _re =
IF (
_date_diff <= 365,
IF (
SELECTEDVALUE ( 'Measure'[Date] ) >= _startDate
&& SELECTEDVALUE ( 'Measure'[Date] ) <= _endDate,
1,
0
),
IF ( SELECTEDVALUE ( 'Measure'[Date] ) > _ture_endDate, 0, 1 )
)
RETURN
_re
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Dear Yang,
many thanks again for your help.
I wasn't able to use the measure exactly as you wrote it but thanks to your suggestion I tweaked it to write two new measures:
To filter the data for the past 4 quarters
- Anonymous2 years agoNot applicable
Hi, Gattinomio
Have you currently resolved this problem, if not, you can share the pbix file without sensitive data for testing, or show your current progress as a picture. From your description, it looks like what you want to do is create a quarterly slicer that filters the first four quarters of data based on the quarterly slicer selection.
Best Regards,
Yang
Community Support Team