Forum Discussion
year differences calculations
Hi Anonymous ,
Please create a new enter table and use [Period range] as the column in the matrix:
Table =
DATATABLE(
"Period range", STRING,
"Order", INTEGER,
{
{"<2 years", 1},
{"2-5 years", 2},
{">5 years", 3}
}
)
Then use this measure as the value of the matrix.
EnhancLead0 =
VAR SelectedYear =
YEAR ( TODAY () ) -- Replace 'Calendar'[Date] with TODAY() if it is relative to today's date.
VAR PrevYear = SelectedYear - 1
VAR FiveYear = SelectedYear - 4
VAR CurrPeriodRange =
SELECTEDVALUE ( 'Table'[Order] )
VAR StartYear =
SWITCH ( CurrPeriodRange, 1, PrevYear, 2, FiveYear, 3, 1900 )
VAR EndYear =
SWITCH ( CurrPeriodRange, 1, SelectedYear, 2, PrevYear - 1, 3, FiveYear - 1 )
VAR Result =
COUNTROWS (
FILTER (
CecCaseDetail,
VAR TopToStateID =
CALCULATE (
SELECTEDVALUE ( CecCaseEvent[ToStateOfProceedingID] ),
TOPN (
1,
FILTER (
ALL ( CecCaseEvent ),
CecCaseEvent[CecCaseID] = CecCaseDetail[CaseID]
&& CecCaseEvent[ToStateOfProceedingID] <> CecCaseEvent[fromstateofproceedingid]
&& RELATED ( 'Calendar'[Year] ) >= StartYear
&& RELATED ( 'Calendar'[Year] ) <= EndYear
),
CecCaseEvent[EventOrder], DESC
)
)
RETURN
TopToStateID
IN { 4 }
&& COUNTROWS (
FILTER ( 'CecLeadingCase', 'CecLeadingCase'[CecCaseId] = CecCaseDetail[CaseID] )
)
)
)
RETURN
Result
Best Regards,
Gao
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
- Anonymous1 year agoNot applicable
Hello Gao,
Thank you for response,
I have question why did you change it (red cicle on the picture) should be there CecCaseEvent[EventDate]
your solution calculates but deliver incorrect values. I believe it has something to do with variable for date and what I highlighted with red circle. Can you look at it again and double check?