【问题标题】:Getting this error: "Expression.Error: The column 't_count' of the table wasn't found. Details: t_count" while executing cummulative sum收到此错误:“Expression.Error: The column 't_count' of the table was not found. Details: t_count” while executioncummulative sum
【发布时间】:2021-03-05 20:33:21
【问题描述】:

您好,我正在尝试为 Power BI 中的“t_count”字段创建累积和,但每次我尝试运行此公式时:List.Sum(List.Range(#"Added Index"[t_count],0,[Hire_Count])) 我收到错误,即在表中找不到t_count 字段。任何人都可以帮助我创建累积金额而不会出现此错误吗?我正在分享来自高级编辑器的完整代码。

   let
        Source = Excel.Workbook(File.Contents("C:\Users\rabi.jaiswal\Desktop\hr_analytics\EMPLOYEE_ATTRITION_DATA.xlsx"), null, true),
        Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
        #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Emp_Id", Int64.Type}, {"Emp_Name", type text}, {"email", type text}, {"Join_Date", type date}, {"Joined_As", type text}, {"Department", type text}, {"Manger_Name", type text}, {"Current_Designation", type text}, {"Current_Designation_Start_Date", type date}, {"Work Hours", Int64.Type}, {"Standard_Work_Hours", Int64.Type}, {"Term_Date", type date}}),
        #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Emp_Id", "Emp_Name", "email", "Joined_As", "Department", "Manger_Name", "Current_Designation", "Current_Designation_Start_Date", "Work Hours", "Standard_Work_Hours"}),
        #"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Join_Date", Order.Ascending}}),
        #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type),
        #"Renamed Columns" = Table.RenameColumns(#"Added Index",{{"Index", "Hire_Count"}}),
        #"Added Conditional Column" = Table.AddColumn(#"Renamed Columns", "t_count", each if [Term_Date] = null then 0 else 1),
        #"Added Custom" = Table.AddColumn(#"Added Conditional Column", "Term_total", each List.Sum(List.Range(#"Added Index"[t_count],0,[Hire_Count])))
    in
        #"Added Custom"

【问题讨论】:

    标签: powerbi powerquery


    【解决方案1】:

    你的索引从一开始,所以试试

        #"Added Custom" = Table.AddColumn(#"Added Conditional Column", "Term_total", each List.Sum(List.FirstN(#"Added Conditional Column"[t_count],[Index]))),
    

    如果你的索引是从零开始的,那就是

        #"Added Custom" = Table.AddColumn(#"Added Conditional Column", "Term_total", each List.Sum(List.FirstN(#"Added Conditional Column"[t_count],[Index]+1))),
    

    【讨论】:

      猜你喜欢
      • 2014-05-13
      • 2016-12-27
      • 2022-12-02
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      • 2021-09-21
      • 1970-01-01
      • 2020-12-23
      相关资源
      最近更新 更多