我需要按保险类型计算预计保费。 计算公式为: 总和(预算) - 总和(当前日的预算)*(1 + BudgetVariance)+ TotalPremium
BudgetVariance = (Premium - Budget tru current Day) / Budget tru current Day
基本上我得到了我需要的所有变量(感谢Joe),但有些人没有正确计算:
BudgetMTD =
VAR DaysOfMonth = MAXX(Dates, DAY(EOMONTH(Dates[Date], 0)))
VAR BudgetPerDayForMonth = SUM(BudgetData[Amount]) / DaysOfMonth
VAR DaysInMonthToToday = MAXX(Dates,
IF(Dates[Date] < TODAY(), DAY(Dates[Date]),
IF(Dates[Date] > TODAY(), 0,
DAY(TODAY())
)))
RETURN BudgetPerDayForMonth * DaysInMonthToToday
BudgetMTD应为25,882,308,但显示30,148,763(这是12个月的总数)。
BudgetVarianceMTD每个月都会正确显示,但在卡片中我需要它:
(Premium - Budget tru current Day) / Budget tru current Day
这是:
28,505,823 - 25,882,308 / 25,882,308 = 0.10136326
答案 0 :(得分:0)
只是从年初到现在的提示
DATEDIFF(month, '2017/01/01', GETDATE()) AS d