I've got a simple model with a earnings(fact) table and a date dimension.
earnings have an earnings period and a systemasof date, earned premium is the amount earned for the earnings period, the systemasof date is the entry date.
the business use is to sum all premium earned for the selected periods, but only if the system as of date is also with the earnings period.
in this example http://sdrv.ms/XuqJoR
the earnings period for 12/25/2012 has an as of date in 2013 for this report it can not be counted for 2012 because it would not have existed until 2013
Selecting january to december 2012 should total 1100.
i have two inactive relationships set up to the date dimension and i am attempting to use the userelated() function to filter the dates but i can not get it to work with both relationships. it works with 2 date tables but not with one roleplaying and it works if i filter the fact but i'm hoping it is faster filtering the dimension and using a relationship.
here are the measures:
This one works but in the real model the earnings table has 250M rows performance should be better filtering against the lookup table
earnings have an earnings period and a systemasof date, earned premium is the amount earned for the earnings period, the systemasof date is the entry date.
the business use is to sum all premium earned for the selected periods, but only if the system as of date is also with the earnings period.
in this example http://sdrv.ms/XuqJoR
the earnings period for 12/25/2012 has an as of date in 2013 for this report it can not be counted for 2012 because it would not have existed until 2013
Selecting january to december 2012 should total 1100.
i have two inactive relationships set up to the date dimension and i am attempting to use the userelated() function to filter the dates but i can not get it to work with both relationships. it works with 2 date tables but not with one roleplaying and it works if i filter the fact but i'm hoping it is faster filtering the dimension and using a relationship.
here are the measures:
This one works but in the real model the earnings table has 250M rows performance should be better filtering against the lookup table
EarnedPrem:=CALCULATE(sum(Earnings[EarnedPremium]),USERELATIONSHIP(DimTime[CALENDARDATE],Earnings[EarningsPeriod]),
filter(values(Earnings[SystemAsOfDate]),Earnings[SystemAsOfDate]<=Max(MonthEnd[MeDate])))
This one does not work, the systemasof relationship is not working as i would expectfilter(values(Earnings[SystemAsOfDate]),Earnings[SystemAsOfDate]<=Max(MonthEnd[MeDate])))
EarningsDimTime:=calculate(CALCULATE(sum(Earnings[EarnedPremium]),USERELATIONSHIP(DimTime[CALENDARDATE],Earnings[EarningsPeriod]))
,USERELATIONSHIP(Earnings[SystemAsOfDate],DimTime[Calendardate]),filter(dimtime,DimTime[Calendardate]<=Max(MonthEnd[MeDate])))
This one works but requires 2 time dimensions, if this is the only choice i'll go with this but dim time should roleplay,USERELATIONSHIP(Earnings[SystemAsOfDate],DimTime[Calendardate]),filter(dimtime,DimTime[Calendardate]<=Max(MonthEnd[MeDate])))
EarningsDimtime2:=calculate(CALCULATE(sum(Earnings[EarnedPremium]),USERELATIONSHIP(DimTime[CALENDARDATE],Earnings[EarningsPeriod]))
,USERELATIONSHIP(Earnings[SystemAsOfDate],DimTime2[Calendardate]),filter(dimtime2,DimTime2[Calendardate]<=Max(MonthEnd[MeDate])))
,USERELATIONSHIP(Earnings[SystemAsOfDate],DimTime2[Calendardate]),filter(dimtime2,DimTime2[Calendardate]<=Max(MonthEnd[MeDate])))
Last edited: