电源查询将长期查询分为多个查询 - 有什么好处吗?
我有一个查询,即(圆数)40个步骤。大多数是添加/变换列,但大约有8个合并查询嵌入的嵌入式
嵌入了多个数据馈送(通过其他查询处理),它们输入此查询(作为数据的根源以及合并查询的根源)。
我们从每个人谈论的记录数量不超过10,000。
以上主要查询需要永远执行。
正在询问将上述40步查询分为几个(使用提取的先前功能)是否有任何好处。
或代替分裂查询,关于如何加快事物的任何想法将最有帮助。
添加了一块代码(由于想显示各种行执行以来,不顺序
let
Source = RMD_Input_File,
#"Added Index" = Table.AddIndexColumn(Source, "Index", 2, 1, Int64.Type),
#"SSN - Text" = Table.AddColumn(#"Added Index", "SSN - Text", each Number.ToText([SSN],"000-00-0000"),type text),
#"Reordered Columns" = Table.ReorderColumns(#"SSN - Text",{"Index", "NameLast", "NameFirst", "NameMi", "SSN", "SSN - Text","PartDOB", "PartDOD", "AnnuityFlag", "Status1", "Status2", "YearsOfSvc", "SpouseSSN", "SpouseDOB", "SpouseDOD", "AcctType", "PartName", "Address1", "Address2", "City", "State", "ZIP", "DCBC Conversion Date", "Plan-1", "Ext-1", "Status-1", "HoldFlag-1", "HoldReason-1", "CurBal-1", "EOYBal-1", "TermDt-1", "Plan-2", "Ext-2", "Status-2", "HoldFlag-2", "HoldReason-2", "CurBal-2", "EOYBal-2", "TermDt-2", "Plan-3", "Ext-3", "Status-3", "HoldFlag-3", "HoldReason-3", "CurBal-3", "EOYBal-3", "TermDt-3", "Plan-4", "Ext-4", "Status-4", "HoldFlag-4", "HoldReason-4", "CurBal-4", "EOYBal-4", "TermDt-4", "Plan-5", "Ext-5", "Status-5", "HoldFlag-5", "HoldReason-5", "CurBal-5", "EOYBal-5", "TermDt-5", "Plan-6", "Ext-6", "Status-6", "HoldFlag-6", "HoldReason-6", "CurBal-6", "EOYBal-6", "TermDt-6", "Plan-7", "Ext-7", "Status-7", "HoldFlag-7", "HoldReason-7", "CurBal-7", "EOYBal-7", "TermDt-7", "Plan-8", "Ext-8", "Status-8", "HoldFlag-8", "HoldReason-8", "CurBal-8", "EOYBal-8", "TermDt-8", "Plan-9", "Ext-9", "Status-9", "HoldFlag-9", "HoldReason-9", "CurBal-9", "EOYBal-9", "TermDt-9", "Plan-10", "Ext-10", "Status-10", "HoldFlag-10", "HoldReason-10", "CurBal-10", "EOYBal-10", "TermDt-10", "Plan-11", "Ext-11", "Status-11", "HoldFlag-11", "HoldReason-11", "CurBal-11", "EOYBal-11", "TermDt-11", "RET_TERM_DATE", "NOTE"}),
#"Replaced Value" = Table.ReplaceValue(#"Reordered Columns",null,"",Replacer.ReplaceValue,{"Status-1", "Status-2", "Status-3", "Status-4", "Status-5", "Status-6", "Status-7", "Status-8", "Status-9", "Status-10", "Status-11"}),
#"1 in Clergy Plan" = Table.AddColumn(#"Replaced Value", "1 in Clergy Plan", each ClergyPlan([#"Plan-1"])),
UpdateStatus1 = Table.ReplaceValue(#"1 in Clergy Plan", each [#"Status-1"], each if [#"Status-1"]>= 20 then [#"Status-1"] else if [1 in Clergy Plan]="Yes" and [PartDOB] < Vlookup("Start Initial", RMD_Dates, "Category", "Date") then 32 else [#"Status-1"], Replacer.ReplaceValue,{"Status-1"}),
#"Active in Plan 1" = Table.AddColumn(UpdateStatus1, "Active in Plan 1", each ActiveInPlan([#"TermDt-1"], [#"Status-1"])),
#"2 in Clergy Plan" = Table.AddColumn(#"Active in Plan 1", "2 in Clergy Plan", each ClergyPlan([#"Plan-2"])),
UpdateStatus2 = Table.ReplaceValue(#"2 in Clergy Plan", each [#"Status-2"], each if [#"Status-2"]>= 20 then [#"Status-2"] else if [2 in Clergy Plan]="Yes" and [PartDOB] < Vlookup("Start Initial", RMD_Dates, "Category", "Date") then 32 else [#"Status-2"], Replacer.ReplaceValue,{"Status-2"}),
#"Active in Plan 2" = Table.AddColumn(UpdateStatus2, "Active in Plan 2", each ActiveInPlan([#"TermDt-2"], [#"Status-2"])),
#"Max Term Date" = Table.AddColumn(#"Active in Plan 11", "Max Term Date", each List.Max({[#"TermDt-1"],[#"TermDt-2"],[#"TermDt-3"],[#"TermDt-4"],[#"TermDt-5"],[#"TermDt-6"],[#"TermDt-7"],[#"TermDt-8"],[#"TermDt-9"],[#"TermDt-10"],[#"TermDt-11"]}),type date),
#"Min Term Date" = Table.AddColumn(#"Max Term Date", "Min Term Date", each List.Min({[#"TermDt-1"],[#"TermDt-2"],[#"TermDt-3"],[#"TermDt-4"],[#"TermDt-5"],[#"TermDt-6"],[#"TermDt-7"],[#"TermDt-8"],[#"TermDt-9"],[#"TermDt-10"],[#"TermDt-11"]}),type date),
RBY = Table.AddColumn(#"Year Reach RMD Age", "RBY", each if [RET_TERM_DATE]=null and [Max Term Date]=null then "" else List.Max({Date.Year([RET_TERM_DATE]),[Year Reach RMD Age],Date.Year([Max Term Date])})),
Initial_or_Reocurring = Table.AddColumn(RBY, "Initial_or_Reocurring", each if [RBY]="" or [RBY]>RMD_Year then "No RMD Due"
else if [RBY]=RMD_Year then "Initial" else "Recurring"),
#"0 in Any Plan" = Table.AddColumn(Initial_or_Reocurring, "0 in Any Plan", each if List.Contains({[#"Status-1"],[#"Status-2"],[#"Status-3"],[#"Status-4"],[#"Status-5"],[#"Status-6"],[#"Status-7"],[#"Status-8"],[#"Status-9"],[#"Status-10"],[#"Status-11"]},0) then "Yes" else "No"),
#"Missing/Foreign Address" = Table.AddColumn(#"0 in Any Plan", "Missing/Foreign Address", each if [ZIP]= null then "Foreign"
else if List.AnyTrue({[Address1]=null,[City]=null, [State]=null}) then "Missing" else null),
ClergyLay = Table.AddColumn(#"Missing/Foreign Address", "ClergyLay", each if List.NonNullCount(List.Distinct({[1 in Clergy Plan],[2 in Clergy Plan],[3 in Clergy Plan],[4 in Clergy Plan],[5 in Clergy Plan],[6 in Clergy Plan],[7 in Clergy Plan],[8 in Clergy Plan],[9 in Clergy Plan],[10 in Clergy Plan],[11 in Clergy Plan]}))=1
then (if List.First(List.Distinct(List.RemoveNulls({[1 in Clergy Plan],[2 in Clergy Plan],[3 in Clergy Plan],[4 in Clergy Plan],[5 in Clergy Plan],[6 in Clergy Plan],[7 in Clergy Plan],[8 in Clergy Plan],[9 in Clergy Plan],[10 in Clergy Plan],[11 in Clergy Plan]}))) ="Yes" then "Clergy" else "Lay")
else "ClergyLay"),
Status = Table.AddColumn(ClergyLay, "Status", each if Vlookup([Status2], status2, "Status2", "Result") = "Deceased" then "Deceased"
else if Vlookup([Status2], status2, "Status2", "Result") = "Active" and [Status1]<>"LE" and [PartDOB]<Vlookup("Start Initial", RMD_Dates, "Category", "Date") and [ClergyLay]= "Clergy" then "Inactive - 72" else Vlookup([Status2], status2, "Status2", "Result")),
#"active in clergy plan or active clergy" = Table.AddColumn(Status, "active in clergy plan or active clergy", each if List.AnyTrue({
[1 in Clergy Plan]="Yes" and [#"Status-1"]<19,
[2 in Clergy Plan]="Yes" and [#"Status-2"]<19,
[3 in Clergy Plan]="Yes" and [#"Status-3"]<19,
[4 in Clergy Plan]="Yes" and [#"Status-4"]<19,
[5 in Clergy Plan]="Yes" and [#"Status-5"]<19,
[6 in Clergy Plan]="Yes" and [#"Status-6"]<19,
[7 in Clergy Plan]="Yes" and [#"Status-7"]<19,
[8 in Clergy Plan]="Yes" and [#"Status-8"]<19,
[9 in Clergy Plan]="Yes" and [#"Status-9"]<19,
[10 in Clergy Plan]="Yes" and [#"Status-10"]<19,
[11 in Clergy Plan]="Yes" and [#"Status-11"]<19,
[Status1]<>"LE" and [Status1]<>"" and [Status]="Active"
}) then "Yes" else "No"),
#"RMD YN-U" = Table.AddColumn(#"active in clergy plan or active clergy", "RMD YN-U", each if List.AnyTrue(
{Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>=20,
Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>=20,
Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>=20,
Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>=20,
Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>=20,
Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>=20,
Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>=20,
Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>=20,
Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>=20,
Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>=20,
Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>=20
}
)
then "RMD" else "No RMD"),
#"Status-U" = Table.AddColumn(#"RMD YN-U", "Status-U", each Text.Combine({
if Text.Start([#"Plan-1"],1)="U" then Number.ToText([#"Status-1"]) else "",
if Text.Start([#"Plan-2"],1)="U" then Number.ToText([#"Status-2"]) else "",
if Text.Start([#"Plan-3"],1)="U" then Number.ToText([#"Status-3"]) else "",
if Text.Start([#"Plan-4"],1)="U" then Number.ToText([#"Status-4"]) else "",
if Text.Start([#"Plan-5"],1)="U" then Number.ToText([#"Status-5"]) else "",
if Text.Start([#"Plan-6"],1)="U" then Number.ToText([#"Status-6"]) else "",
if Text.Start([#"Plan-7"],1)="U" then Number.ToText([#"Status-7"]) else "",
if Text.Start([#"Plan-8"],1)="U" then Number.ToText([#"Status-8"]) else "",
if Text.Start([#"Plan-9"],1)="U" then Number.ToText([#"Status-9"]) else "",
if Text.Start([#"Plan-10"],1)="U" then Number.ToText([#"Status-10"]) else "",
if Text.Start([#"Plan-11"],1)="U" then Number.ToText([#"Status-11"]) else ""
},",")),
#"adjCurBal-U" = Table.AddColumn(#"EOYBal-U", "adjCurBal-U", each if [active in clergy plan or active clergy] = "Yes" then
List.Sum(
{if List.AnyTrue({Text.Start([#"Plan-1"],2)="UM",Text.Start([#"Plan-1"],2)="UC",[#"Plan-1"]="U99999"}) then 0
else if Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>19 then [#"CurBal-1"] else 0,
if List.AnyTrue({Text.Start([#"Plan-2"],2)="UM",Text.Start([#"Plan-2"],2)="UC",[#"Plan-2"]="U99999"}) then 0
else if Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>19 then [#"CurBal-2"] else 0,
if List.AnyTrue({Text.Start([#"Plan-3"],2)="UM",Text.Start([#"Plan-3"],2)="UC",[#"Plan-3"]="U99999"}) then 0
else if Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>19 then [#"CurBal-3"] else 0,
if List.AnyTrue({Text.Start([#"Plan-4"],2)="UM",Text.Start([#"Plan-4"],2)="UC",[#"Plan-4"]="U99999"}) then 0
else if Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>19 then [#"CurBal-4"] else 0,
if List.AnyTrue({Text.Start([#"Plan-5"],2)="UM",Text.Start([#"Plan-5"],2)="UC",[#"Plan-5"]="U99999"}) then 0
else if Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>19 then [#"CurBal-5"] else 0,
if List.AnyTrue({Text.Start([#"Plan-6"],2)="UM",Text.Start([#"Plan-6"],2)="UC",[#"Plan-6"]="U99999"}) then 0
else if Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>19 then [#"CurBal-6"] else 0,
if List.AnyTrue({Text.Start([#"Plan-7"],2)="UM",Text.Start([#"Plan-7"],2)="UC",[#"Plan-7"]="U99999"}) then 0
else if Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>19 then [#"CurBal-7"] else 0,
if List.AnyTrue({Text.Start([#"Plan-8"],2)="UM",Text.Start([#"Plan-8"],2)="UC",[#"Plan-8"]="U99999"}) then 0
else if Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>19 then [#"CurBal-8"] else 0,
if List.AnyTrue({Text.Start([#"Plan-9"],2)="UM",Text.Start([#"Plan-9"],2)="UC",[#"Plan-9"]="U99999"}) then 0
else if Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>19 then [#"CurBal-9"] else 0,
if List.AnyTrue({Text.Start([#"Plan-10"],2)="UM",Text.Start([#"Plan-10"],2)="UC",[#"Plan-10"]="U99999"}) then 0
else if Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>19 then [#"CurBal-10"] else 0,
if List.AnyTrue({Text.Start([#"Plan-11"],2)="UM",Text.Start([#"Plan-11"],2)="UC",[#"Plan-11"]="U99999"}) then 0
else if Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>19 then [#"CurBal-11"] else 0}
)
else
List.Sum({if Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>19 then [#"CurBal-1"] else 0,
if Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>19 then [#"CurBal-2"] else 0,
if Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>19 then [#"CurBal-3"] else 0,
if Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>19 then [#"CurBal-4"] else 0,
if Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>19 then [#"CurBal-5"] else 0,
if Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>19 then [#"CurBal-6"] else 0,
if Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>19 then [#"CurBal-7"] else 0,
if Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>19 then [#"CurBal-8"] else 0,
if Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>19 then [#"CurBal-9"] else 0,
if Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>19 then [#"CurBal-10"] else 0,
if Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>19 then [#"CurBal-11"] else 0
})),
#"adjEOYBal-U" = Table.AddColumn(#"adjCurBal-U", "adjEOYBal-U", each if [active in clergy plan or active clergy] = "Yes" then
List.Sum(
{if List.AnyTrue({Text.Start([#"Plan-1"],2)="UM",Text.Start([#"Plan-1"],2)="UC",[#"Plan-1"]="U99999"}) then 0
else if Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>19 then [#"EOYBal-1"] else 0,
if List.AnyTrue({Text.Start([#"Plan-2"],2)="UM",Text.Start([#"Plan-2"],2)="UC",[#"Plan-2"]="U99999"}) then 0
else if Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>19 then [#"EOYBal-2"] else 0,
if List.AnyTrue({Text.Start([#"Plan-3"],2)="UM",Text.Start([#"Plan-3"],2)="UC",[#"Plan-3"]="U99999"}) then 0
else if Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>19 then [#"EOYBal-3"] else 0,
if List.AnyTrue({Text.Start([#"Plan-4"],2)="UM",Text.Start([#"Plan-4"],2)="UC",[#"Plan-4"]="U99999"}) then 0
else if Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>19 then [#"EOYBal-4"] else 0,
if List.AnyTrue({Text.Start([#"Plan-5"],2)="UM",Text.Start([#"Plan-5"],2)="UC",[#"Plan-5"]="U99999"}) then 0
else if Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>19 then [#"EOYBal-5"] else 0,
if List.AnyTrue({Text.Start([#"Plan-6"],2)="UM",Text.Start([#"Plan-6"],2)="UC",[#"Plan-6"]="U99999"}) then 0
else if Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>19 then [#"EOYBal-6"] else 0,
if List.AnyTrue({Text.Start([#"Plan-7"],2)="UM",Text.Start([#"Plan-7"],2)="UC",[#"Plan-7"]="U99999"}) then 0
else if Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>19 then [#"EOYBal-7"] else 0,
if List.AnyTrue({Text.Start([#"Plan-8"],2)="UM",Text.Start([#"Plan-8"],2)="UC",[#"Plan-8"]="U99999"}) then 0
else if Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>19 then [#"EOYBal-8"] else 0,
if List.AnyTrue({Text.Start([#"Plan-9"],2)="UM",Text.Start([#"Plan-9"],2)="UC",[#"Plan-9"]="U99999"}) then 0
else if Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>19 then [#"EOYBal-9"] else 0,
if List.AnyTrue({Text.Start([#"Plan-10"],2)="UM",Text.Start([#"Plan-10"],2)="UC",[#"Plan-10"]="U99999"}) then 0
else if Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>19 then [#"EOYBal-10"] else 0,
if List.AnyTrue({Text.Start([#"Plan-11"],2)="UM",Text.Start([#"Plan-11"],2)="UC",[#"Plan-11"]="U99999"}) then 0
else if Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>19 then [#"EOYBal-11"] else 0}
)
else
List.Sum({if Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>19 then [#"EOYBal-1"] else 0,
if Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>19 then [#"EOYBal-2"] else 0,
if Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>19 then [#"EOYBal-3"] else 0,
if Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>19 then [#"EOYBal-4"] else 0,
if Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>19 then [#"EOYBal-5"] else 0,
if Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>19 then [#"EOYBal-6"] else 0,
if Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>19 then [#"EOYBal-7"] else 0,
if Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>19 then [#"EOYBal-8"] else 0,
if Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>19 then [#"EOYBal-9"] else 0,
if Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>19 then [#"EOYBal-10"] else 0,
if Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>19 then [#"EOYBal-11"] else 0
})),
I have a query which is (round numbers) 40 steps in length. Most are Add/Transform Columns but there are about 8 merge queried embedded
There are multiple data feeds upfront (handled by other queries) which feed into this query (as the root source of data as well as for the merge queries).
The number of records we are talking from each is no more than 10,000.
The above main query takes forever to execute.
Am asking whether there is any benefit to splitting the above 40 step query into several (using the Extract Previous functionality).
Or in lieu of splitting the query, any ideas on how to speed things up would be most helpful.
Added chunks of code (non-sequential since wanted to show various line executions
let
Source = RMD_Input_File,
#"Added Index" = Table.AddIndexColumn(Source, "Index", 2, 1, Int64.Type),
#"SSN - Text" = Table.AddColumn(#"Added Index", "SSN - Text", each Number.ToText([SSN],"000-00-0000"),type text),
#"Reordered Columns" = Table.ReorderColumns(#"SSN - Text",{"Index", "NameLast", "NameFirst", "NameMi", "SSN", "SSN - Text","PartDOB", "PartDOD", "AnnuityFlag", "Status1", "Status2", "YearsOfSvc", "SpouseSSN", "SpouseDOB", "SpouseDOD", "AcctType", "PartName", "Address1", "Address2", "City", "State", "ZIP", "DCBC Conversion Date", "Plan-1", "Ext-1", "Status-1", "HoldFlag-1", "HoldReason-1", "CurBal-1", "EOYBal-1", "TermDt-1", "Plan-2", "Ext-2", "Status-2", "HoldFlag-2", "HoldReason-2", "CurBal-2", "EOYBal-2", "TermDt-2", "Plan-3", "Ext-3", "Status-3", "HoldFlag-3", "HoldReason-3", "CurBal-3", "EOYBal-3", "TermDt-3", "Plan-4", "Ext-4", "Status-4", "HoldFlag-4", "HoldReason-4", "CurBal-4", "EOYBal-4", "TermDt-4", "Plan-5", "Ext-5", "Status-5", "HoldFlag-5", "HoldReason-5", "CurBal-5", "EOYBal-5", "TermDt-5", "Plan-6", "Ext-6", "Status-6", "HoldFlag-6", "HoldReason-6", "CurBal-6", "EOYBal-6", "TermDt-6", "Plan-7", "Ext-7", "Status-7", "HoldFlag-7", "HoldReason-7", "CurBal-7", "EOYBal-7", "TermDt-7", "Plan-8", "Ext-8", "Status-8", "HoldFlag-8", "HoldReason-8", "CurBal-8", "EOYBal-8", "TermDt-8", "Plan-9", "Ext-9", "Status-9", "HoldFlag-9", "HoldReason-9", "CurBal-9", "EOYBal-9", "TermDt-9", "Plan-10", "Ext-10", "Status-10", "HoldFlag-10", "HoldReason-10", "CurBal-10", "EOYBal-10", "TermDt-10", "Plan-11", "Ext-11", "Status-11", "HoldFlag-11", "HoldReason-11", "CurBal-11", "EOYBal-11", "TermDt-11", "RET_TERM_DATE", "NOTE"}),
#"Replaced Value" = Table.ReplaceValue(#"Reordered Columns",null,"",Replacer.ReplaceValue,{"Status-1", "Status-2", "Status-3", "Status-4", "Status-5", "Status-6", "Status-7", "Status-8", "Status-9", "Status-10", "Status-11"}),
#"1 in Clergy Plan" = Table.AddColumn(#"Replaced Value", "1 in Clergy Plan", each ClergyPlan([#"Plan-1"])),
UpdateStatus1 = Table.ReplaceValue(#"1 in Clergy Plan", each [#"Status-1"], each if [#"Status-1"]>= 20 then [#"Status-1"] else if [1 in Clergy Plan]="Yes" and [PartDOB] < Vlookup("Start Initial", RMD_Dates, "Category", "Date") then 32 else [#"Status-1"], Replacer.ReplaceValue,{"Status-1"}),
#"Active in Plan 1" = Table.AddColumn(UpdateStatus1, "Active in Plan 1", each ActiveInPlan([#"TermDt-1"], [#"Status-1"])),
#"2 in Clergy Plan" = Table.AddColumn(#"Active in Plan 1", "2 in Clergy Plan", each ClergyPlan([#"Plan-2"])),
UpdateStatus2 = Table.ReplaceValue(#"2 in Clergy Plan", each [#"Status-2"], each if [#"Status-2"]>= 20 then [#"Status-2"] else if [2 in Clergy Plan]="Yes" and [PartDOB] < Vlookup("Start Initial", RMD_Dates, "Category", "Date") then 32 else [#"Status-2"], Replacer.ReplaceValue,{"Status-2"}),
#"Active in Plan 2" = Table.AddColumn(UpdateStatus2, "Active in Plan 2", each ActiveInPlan([#"TermDt-2"], [#"Status-2"])),
#"Max Term Date" = Table.AddColumn(#"Active in Plan 11", "Max Term Date", each List.Max({[#"TermDt-1"],[#"TermDt-2"],[#"TermDt-3"],[#"TermDt-4"],[#"TermDt-5"],[#"TermDt-6"],[#"TermDt-7"],[#"TermDt-8"],[#"TermDt-9"],[#"TermDt-10"],[#"TermDt-11"]}),type date),
#"Min Term Date" = Table.AddColumn(#"Max Term Date", "Min Term Date", each List.Min({[#"TermDt-1"],[#"TermDt-2"],[#"TermDt-3"],[#"TermDt-4"],[#"TermDt-5"],[#"TermDt-6"],[#"TermDt-7"],[#"TermDt-8"],[#"TermDt-9"],[#"TermDt-10"],[#"TermDt-11"]}),type date),
RBY = Table.AddColumn(#"Year Reach RMD Age", "RBY", each if [RET_TERM_DATE]=null and [Max Term Date]=null then "" else List.Max({Date.Year([RET_TERM_DATE]),[Year Reach RMD Age],Date.Year([Max Term Date])})),
Initial_or_Reocurring = Table.AddColumn(RBY, "Initial_or_Reocurring", each if [RBY]="" or [RBY]>RMD_Year then "No RMD Due"
else if [RBY]=RMD_Year then "Initial" else "Recurring"),
#"0 in Any Plan" = Table.AddColumn(Initial_or_Reocurring, "0 in Any Plan", each if List.Contains({[#"Status-1"],[#"Status-2"],[#"Status-3"],[#"Status-4"],[#"Status-5"],[#"Status-6"],[#"Status-7"],[#"Status-8"],[#"Status-9"],[#"Status-10"],[#"Status-11"]},0) then "Yes" else "No"),
#"Missing/Foreign Address" = Table.AddColumn(#"0 in Any Plan", "Missing/Foreign Address", each if [ZIP]= null then "Foreign"
else if List.AnyTrue({[Address1]=null,[City]=null, [State]=null}) then "Missing" else null),
ClergyLay = Table.AddColumn(#"Missing/Foreign Address", "ClergyLay", each if List.NonNullCount(List.Distinct({[1 in Clergy Plan],[2 in Clergy Plan],[3 in Clergy Plan],[4 in Clergy Plan],[5 in Clergy Plan],[6 in Clergy Plan],[7 in Clergy Plan],[8 in Clergy Plan],[9 in Clergy Plan],[10 in Clergy Plan],[11 in Clergy Plan]}))=1
then (if List.First(List.Distinct(List.RemoveNulls({[1 in Clergy Plan],[2 in Clergy Plan],[3 in Clergy Plan],[4 in Clergy Plan],[5 in Clergy Plan],[6 in Clergy Plan],[7 in Clergy Plan],[8 in Clergy Plan],[9 in Clergy Plan],[10 in Clergy Plan],[11 in Clergy Plan]}))) ="Yes" then "Clergy" else "Lay")
else "ClergyLay"),
Status = Table.AddColumn(ClergyLay, "Status", each if Vlookup([Status2], status2, "Status2", "Result") = "Deceased" then "Deceased"
else if Vlookup([Status2], status2, "Status2", "Result") = "Active" and [Status1]<>"LE" and [PartDOB]<Vlookup("Start Initial", RMD_Dates, "Category", "Date") and [ClergyLay]= "Clergy" then "Inactive - 72" else Vlookup([Status2], status2, "Status2", "Result")),
#"active in clergy plan or active clergy" = Table.AddColumn(Status, "active in clergy plan or active clergy", each if List.AnyTrue({
[1 in Clergy Plan]="Yes" and [#"Status-1"]<19,
[2 in Clergy Plan]="Yes" and [#"Status-2"]<19,
[3 in Clergy Plan]="Yes" and [#"Status-3"]<19,
[4 in Clergy Plan]="Yes" and [#"Status-4"]<19,
[5 in Clergy Plan]="Yes" and [#"Status-5"]<19,
[6 in Clergy Plan]="Yes" and [#"Status-6"]<19,
[7 in Clergy Plan]="Yes" and [#"Status-7"]<19,
[8 in Clergy Plan]="Yes" and [#"Status-8"]<19,
[9 in Clergy Plan]="Yes" and [#"Status-9"]<19,
[10 in Clergy Plan]="Yes" and [#"Status-10"]<19,
[11 in Clergy Plan]="Yes" and [#"Status-11"]<19,
[Status1]<>"LE" and [Status1]<>"" and [Status]="Active"
}) then "Yes" else "No"),
#"RMD YN-U" = Table.AddColumn(#"active in clergy plan or active clergy", "RMD YN-U", each if List.AnyTrue(
{Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>=20,
Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>=20,
Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>=20,
Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>=20,
Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>=20,
Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>=20,
Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>=20,
Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>=20,
Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>=20,
Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>=20,
Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>=20
}
)
then "RMD" else "No RMD"),
#"Status-U" = Table.AddColumn(#"RMD YN-U", "Status-U", each Text.Combine({
if Text.Start([#"Plan-1"],1)="U" then Number.ToText([#"Status-1"]) else "",
if Text.Start([#"Plan-2"],1)="U" then Number.ToText([#"Status-2"]) else "",
if Text.Start([#"Plan-3"],1)="U" then Number.ToText([#"Status-3"]) else "",
if Text.Start([#"Plan-4"],1)="U" then Number.ToText([#"Status-4"]) else "",
if Text.Start([#"Plan-5"],1)="U" then Number.ToText([#"Status-5"]) else "",
if Text.Start([#"Plan-6"],1)="U" then Number.ToText([#"Status-6"]) else "",
if Text.Start([#"Plan-7"],1)="U" then Number.ToText([#"Status-7"]) else "",
if Text.Start([#"Plan-8"],1)="U" then Number.ToText([#"Status-8"]) else "",
if Text.Start([#"Plan-9"],1)="U" then Number.ToText([#"Status-9"]) else "",
if Text.Start([#"Plan-10"],1)="U" then Number.ToText([#"Status-10"]) else "",
if Text.Start([#"Plan-11"],1)="U" then Number.ToText([#"Status-11"]) else ""
},",")),
#"adjCurBal-U" = Table.AddColumn(#"EOYBal-U", "adjCurBal-U", each if [active in clergy plan or active clergy] = "Yes" then
List.Sum(
{if List.AnyTrue({Text.Start([#"Plan-1"],2)="UM",Text.Start([#"Plan-1"],2)="UC",[#"Plan-1"]="U99999"}) then 0
else if Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>19 then [#"CurBal-1"] else 0,
if List.AnyTrue({Text.Start([#"Plan-2"],2)="UM",Text.Start([#"Plan-2"],2)="UC",[#"Plan-2"]="U99999"}) then 0
else if Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>19 then [#"CurBal-2"] else 0,
if List.AnyTrue({Text.Start([#"Plan-3"],2)="UM",Text.Start([#"Plan-3"],2)="UC",[#"Plan-3"]="U99999"}) then 0
else if Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>19 then [#"CurBal-3"] else 0,
if List.AnyTrue({Text.Start([#"Plan-4"],2)="UM",Text.Start([#"Plan-4"],2)="UC",[#"Plan-4"]="U99999"}) then 0
else if Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>19 then [#"CurBal-4"] else 0,
if List.AnyTrue({Text.Start([#"Plan-5"],2)="UM",Text.Start([#"Plan-5"],2)="UC",[#"Plan-5"]="U99999"}) then 0
else if Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>19 then [#"CurBal-5"] else 0,
if List.AnyTrue({Text.Start([#"Plan-6"],2)="UM",Text.Start([#"Plan-6"],2)="UC",[#"Plan-6"]="U99999"}) then 0
else if Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>19 then [#"CurBal-6"] else 0,
if List.AnyTrue({Text.Start([#"Plan-7"],2)="UM",Text.Start([#"Plan-7"],2)="UC",[#"Plan-7"]="U99999"}) then 0
else if Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>19 then [#"CurBal-7"] else 0,
if List.AnyTrue({Text.Start([#"Plan-8"],2)="UM",Text.Start([#"Plan-8"],2)="UC",[#"Plan-8"]="U99999"}) then 0
else if Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>19 then [#"CurBal-8"] else 0,
if List.AnyTrue({Text.Start([#"Plan-9"],2)="UM",Text.Start([#"Plan-9"],2)="UC",[#"Plan-9"]="U99999"}) then 0
else if Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>19 then [#"CurBal-9"] else 0,
if List.AnyTrue({Text.Start([#"Plan-10"],2)="UM",Text.Start([#"Plan-10"],2)="UC",[#"Plan-10"]="U99999"}) then 0
else if Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>19 then [#"CurBal-10"] else 0,
if List.AnyTrue({Text.Start([#"Plan-11"],2)="UM",Text.Start([#"Plan-11"],2)="UC",[#"Plan-11"]="U99999"}) then 0
else if Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>19 then [#"CurBal-11"] else 0}
)
else
List.Sum({if Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>19 then [#"CurBal-1"] else 0,
if Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>19 then [#"CurBal-2"] else 0,
if Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>19 then [#"CurBal-3"] else 0,
if Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>19 then [#"CurBal-4"] else 0,
if Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>19 then [#"CurBal-5"] else 0,
if Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>19 then [#"CurBal-6"] else 0,
if Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>19 then [#"CurBal-7"] else 0,
if Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>19 then [#"CurBal-8"] else 0,
if Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>19 then [#"CurBal-9"] else 0,
if Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>19 then [#"CurBal-10"] else 0,
if Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>19 then [#"CurBal-11"] else 0
})),
#"adjEOYBal-U" = Table.AddColumn(#"adjCurBal-U", "adjEOYBal-U", each if [active in clergy plan or active clergy] = "Yes" then
List.Sum(
{if List.AnyTrue({Text.Start([#"Plan-1"],2)="UM",Text.Start([#"Plan-1"],2)="UC",[#"Plan-1"]="U99999"}) then 0
else if Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>19 then [#"EOYBal-1"] else 0,
if List.AnyTrue({Text.Start([#"Plan-2"],2)="UM",Text.Start([#"Plan-2"],2)="UC",[#"Plan-2"]="U99999"}) then 0
else if Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>19 then [#"EOYBal-2"] else 0,
if List.AnyTrue({Text.Start([#"Plan-3"],2)="UM",Text.Start([#"Plan-3"],2)="UC",[#"Plan-3"]="U99999"}) then 0
else if Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>19 then [#"EOYBal-3"] else 0,
if List.AnyTrue({Text.Start([#"Plan-4"],2)="UM",Text.Start([#"Plan-4"],2)="UC",[#"Plan-4"]="U99999"}) then 0
else if Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>19 then [#"EOYBal-4"] else 0,
if List.AnyTrue({Text.Start([#"Plan-5"],2)="UM",Text.Start([#"Plan-5"],2)="UC",[#"Plan-5"]="U99999"}) then 0
else if Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>19 then [#"EOYBal-5"] else 0,
if List.AnyTrue({Text.Start([#"Plan-6"],2)="UM",Text.Start([#"Plan-6"],2)="UC",[#"Plan-6"]="U99999"}) then 0
else if Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>19 then [#"EOYBal-6"] else 0,
if List.AnyTrue({Text.Start([#"Plan-7"],2)="UM",Text.Start([#"Plan-7"],2)="UC",[#"Plan-7"]="U99999"}) then 0
else if Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>19 then [#"EOYBal-7"] else 0,
if List.AnyTrue({Text.Start([#"Plan-8"],2)="UM",Text.Start([#"Plan-8"],2)="UC",[#"Plan-8"]="U99999"}) then 0
else if Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>19 then [#"EOYBal-8"] else 0,
if List.AnyTrue({Text.Start([#"Plan-9"],2)="UM",Text.Start([#"Plan-9"],2)="UC",[#"Plan-9"]="U99999"}) then 0
else if Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>19 then [#"EOYBal-9"] else 0,
if List.AnyTrue({Text.Start([#"Plan-10"],2)="UM",Text.Start([#"Plan-10"],2)="UC",[#"Plan-10"]="U99999"}) then 0
else if Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>19 then [#"EOYBal-10"] else 0,
if List.AnyTrue({Text.Start([#"Plan-11"],2)="UM",Text.Start([#"Plan-11"],2)="UC",[#"Plan-11"]="U99999"}) then 0
else if Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>19 then [#"EOYBal-11"] else 0}
)
else
List.Sum({if Text.Start([#"Plan-1"],1)="U" and [#"Status-1"]>19 then [#"EOYBal-1"] else 0,
if Text.Start([#"Plan-2"],1)="U" and [#"Status-2"]>19 then [#"EOYBal-2"] else 0,
if Text.Start([#"Plan-3"],1)="U" and [#"Status-3"]>19 then [#"EOYBal-3"] else 0,
if Text.Start([#"Plan-4"],1)="U" and [#"Status-4"]>19 then [#"EOYBal-4"] else 0,
if Text.Start([#"Plan-5"],1)="U" and [#"Status-5"]>19 then [#"EOYBal-5"] else 0,
if Text.Start([#"Plan-6"],1)="U" and [#"Status-6"]>19 then [#"EOYBal-6"] else 0,
if Text.Start([#"Plan-7"],1)="U" and [#"Status-7"]>19 then [#"EOYBal-7"] else 0,
if Text.Start([#"Plan-8"],1)="U" and [#"Status-8"]>19 then [#"EOYBal-8"] else 0,
if Text.Start([#"Plan-9"],1)="U" and [#"Status-9"]>19 then [#"EOYBal-9"] else 0,
if Text.Start([#"Plan-10"],1)="U" and [#"Status-10"]>19 then [#"EOYBal-10"] else 0,
if Text.Start([#"Plan-11"],1)="U" and [#"Status-11"]>19 then [#"EOYBal-11"] else 0
})),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论