Forum Discussion
3 Year Claims using Policy Level Context - Applying Context Transition
- 1 year ago
Hi all,
Apologies for the slow reply on this. I've come up with a working solution, specifically, creating a dummy column linking to a policy term and then creating a bi-directional relationship to establish a max date relative to the dimension.
I've provided the code below for those who may find this useful.
VAR MaxDate =MAX ( 'Date Table'[Date] )VAR ClaimsTable =ADDCOLUMNS (CALCULATETABLE(VALUES ( Claims[PolicyNumber] ), REMOVEFILTERS('Date Table')),"GWP",VAR RenewalDate =-- Bidirectional relationship to Dimension table to establish the max date relative to date aboveCALCULATE (MAX ( 'Policy Term'[PolicyTermStartDate] ),'Policy Term'[PolicyTermStartDate] <= MaxDate,CROSSFILTER ( 'Policy Term'[PolicyNumber], Claims[PolicyNumber], BOTH ),USERELATIONSHIP ( 'Policy Term'[PolicyNumber], Claims[PolicyNumber] ), --Default relationship is usually the term IDREMOVEFILTERS('Date Table'))VAR ThreeYearStart =EDATE ( RenewalDate, -36 )VAR CutOff =EDATE ( RenewalDate, -3 )RETURNCALCULATE (SUM ( Claims[GrossIncurred] ),Claims[EventDate] <= CutOff && Claims[EventDate] >= ThreeYearStart,Claims[TransactionDate] <= CutOff,REMOVEFILTERS ( 'Date Table' )))RETURNSUMX ( ClaimsTable, [GWP] )
Any feedback on optimisation would be appriciated though!Thanks,
Will
Hi all,
Apologies for the slow reply on this. I've come up with a working solution, specifically, creating a dummy column linking to a policy term and then creating a bi-directional relationship to establish a max date relative to the dimension.
I've provided the code below for those who may find this useful.
Any feedback on optimisation would be appriciated though!
Thanks,
Will