Forum Discussion
pradeept
Resolver I
5 years agoDefault Selection for Latest Period (Data for Latest Period)
Hi Community, Need your help. Sceanrio: I have 2 slicers in one page. Year (YYYY) and Month (YYYYMM). 1) When I open the the dashboard, the slicer has to set for the latest Year and latest...
- 5 years ago
Anonymous thanks for your help.
I don't want to use the static dates; the dates should be dynamic, in measures calculation.I tried to overcome the filtering at each visual as well.Finally got some solution, after tweaking my initial DAX measure. Here is the DAX measure calculation I used to achieve this..SalesAmount Latest Period=Var _MaxReportPeriod =CALCULATE(MAX(Sales[ReportingPeriod]),ALLEXCEPT(Sales,Sales[ReportingPeriod],Sales[ReportingYear]))RETURNCALCULATE(SUM(Sales[Amount]), Sales[ReportingPeriod] = _MaxReportPeriod)
Anonymous
5 years agoNot applicable
Hi pradeept ,
According to your description, I create some data:
Here are the steps you can follow:
1. Create calculated Table.
Slicer = SUMMARIZE('Table',[Year])
2. Create measure.
Flag =
var _selectyear=HASONEVALUE('Slicer'[Year])
var _selectmonth=HASONEVALUE('Table'[Month])
return
SWITCH(
TRUE(), _selectyear=FALSE()&&_selectmonth=FALSE(),CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),MONTH('Table'[date])=3&&YEAR('Table'[date])=2021)),
_selectyear=FALSE(),SUM('Table'[amount]),
_selectmonth=FALSE(),CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),MONTH('Table'[date])=12&&YEAR('Table'[date])=SELECTEDVALUE(Slicer[Year]))),
BLANK())
3. Place the measure in the Filter, select is =1, Apply filter.
4. Result.
By default, the data for the month of 2021.3 are displayed:
Select 2020, you should display the data for 202012:
Select 201910, it will display the data for October 2019:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.