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 ,
Here are the steps you can follow:
1. Create a table of two slicers
Slicer1 = SUMMARIZE('Table',[Year])Slicer2 = SUMMARIZE('Table',[Month])
2. Create measure.
Flag =
var _selectyear=HASONEVALUE('Slicer1'[Year])
var _selectmonth=HASONEVALUE('Slicer2'[Month])
return
SWITCH(
TRUE(),
_selectyear=FALSE()&&_selectmonth=FALSE(),IF(MONTH(MAX('Table'[date]))=4&&YEAR(MAX('Table'[date]))=2021,1,0),
_selectyear=FALSE(),IF(MAX('Table'[Month])=SELECTEDVALUE(Slicer2[Month]),1,0),
_selectmonth=FALSE(),IF(SELECTEDVALUE(Slicer1[Year])=2020,IF(MAX('Table'[Month])=202012,1,0),IF(MAX('Table'[Month])=20214,1,0)),
IF(MAX('Table'[Month])=SELECTEDVALUE(Slicer2[Month]),1,0)
)
3. Place the measure in the Filter, select is =1, Apply filter.
4. Result.
When 2021 is selected or not, the following is displayed:
When 2020 is selected, the result shows:
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.
pradeept
Resolver I
5 years agoAnonymous 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])
)
RETURN
CALCULATE(
SUM(Sales[Amount]), Sales[ReportingPeriod] = _MaxReportPeriod
)