Forum Discussion
rcorn
4 years agoFrequent Visitor
Dynamically get top 12 time periods when switching between date field parameters
All - I am trying to show the most recent twelve date results for each selection "Year", "Quarter and Year", and "Month and Year" which are field parameters from my date table 'date'. Date T...
Anonymous
4 years agoNot applicable
Hi
Yes, you can create a measure that checks which data format is in scope and then filter the 12 most recent dates.
Something like this:
Volume Last 12 Periods =
RETURN
SWITCH (
TRUE (),
ISINSCOPE ( Date[Year] ),
CALCULATE(
[Volume],
DATESINPERIOD(
'Date'[Date],
MAX('Date'[Date]),
-12,
YEAR
)
)
),
ISINSCOPE ( Date[Quarter] ) && ISINSCOPE ( Date[Year] ),
CALCULATE(
[Volume],
DATESINPERIOD(
'Date'[Date],
MAX('Date'[Date]),
-12,
QUARTER
)
),
ISINSCOPE ( Date[Month] ) && ISINSCOPE ( Date[Year] ),
CALCULATE(
[Volume],
DATESINPERIOD(
'Date'[Date],
MAX('Date'[Date]),
-12,
MONTH
)
)
)
Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
- rcorn4 years agoFrequent Visitor
This did not work, it did not get rid of dates prior to the most recent 12 time periods and sum of the volume was inaccurate.
- Anonymous4 years agoNot applicable
Would you mind sharing a pbix file with some sample data?
- rcorn4 years agoFrequent Visitor
I am not certain about how to share, there is no choose file option on the reply.