Excel公式-按员工编号排列日期

时间:2019-01-29 10:08:21

标签: excel

我有员工和日期表。一些emp在其列(“ E”)中是Duplicates,并且在表中的行中可以有多个。每行在“ W”列中都有日期。我想找到一种按最新日期对员工的每一行进行排名的方法。

例如:

empNum Date
112311 12/10/2016
112311 11/09/2015
122311 06/08/2018
144533 23/03/2012
144533 01/11/2018

first row rank = 2
second row rank = 1
third row rank = 3
fourth row rank = 1 
fitth row rank = 2  

4 个答案:

答案 0 :(得分:0)

假设单元格A1的值为empNum,并且数据是连续的,则以下公式应会有所帮助:

=RANK.EQ(B2,$B$2:$B$4,1)

https://exceljet.net/excel-functions/excel-rank.eq-function

  

Excel RANK.EQ函数针对列表返回数字的排名   其他数值。

您可能想指定我们需要对empNum进行的操作,而是提供一个包含5行的示例,其中包含2个不同的empNum

答案 1 :(得分:0)

如果您考虑RANK实际完成的工作,那么在该雇员的日期组内排列每个雇员的日期是一件简单的事情;具体来说,排名是指任何一名员工的日期小于或等于任一日期的日期数。 COUNTIFS可以做到。

=countifs(a:a, a2, b:b, "<="&b2)

我猜到 122311 是一个错字。

enter image description here

答案 2 :(得分:0)

“在组中排名”

您要搜索的是“组内排名”。可以通过多种方式实现相同的目标:

方法1:

=SUMPRODUCT(($A$2:$A$6=A2)*(B2>$B$2:$B$6))+1

方法2: 如@ user10981853

所述
=countifs(a:a, a2, b:b, "<="&b2)

Discussion thread to same problem

答案 3 :(得分:0)

您的“排名”似乎是同一员工编号的日期数等于该行的日期,再加上1,因此应该可以:

library(shiny)
library(lubridate)
library(DiagrammeR)
library(tidyr)

# --- Input datafile
AllData <- data.frame(Project = c("Phoenix", "Phoenix", "Phoenix"),  
                      task = c("Establish plan", "Build management tool", "Get funding"),
                      status = c("done", "active", "crit, active"),
                      pos = c("first_1", "first_2", "import_1"),
                      start = c("2018-12-01", "2019-01-21", "2019-02-01"),
                      end = c("12w 6d", "4w", "8w 1d"),
                      stringsAsFactors = FALSE)

# Define UI for application

ui <- fluidPage(

  titlePanel("XXX Project Management Tool"),

  sidebarLayout(
    sidebarPanel(                       # --- setup LHS data input frames ---


      selectInput("Proj", "Project",
                  c(unique(as.character(AllData$Project)))),


      selectInput("Stg", "Stage",
                  c("All", unique(as.character(AllData$name)))),

      width = 3),

    mainPanel(

      tabsetPanel(type = "tabs",
                  tabPanel("Gantt Chart", DiagrammeROutput("plot")),
                  tabPanel("Data Table", tableOutput("table"))))

  )
)

server <- function(input, output) {

  # --- filter the selected project into a reactive function (access later using () suffix) ---
  SelectedProject <- reactive({dplyr::filter(AllData, Project == input$Proj)})

  output$plot <- renderDiagrammeR({
    mermaid(
      paste0(
        "gantt", "\n", 
        "dateFormat  YYYY-MM-DD", "\n", 
        "title Gantt Chart - Project ", input$Proj, "\n",

        # --- unite the first two columns (task & status) and separate them with ":" ---
        # --- then, unite the other columns and separate them with "," ---
        paste(SelectedProject() %>%
                unite(i, task, status, sep = ":") %>%
                unite(j, i, pos, start, end, sep = ",") %>%
                .$j, 
              collapse = "\n"
        ), "\n"
      )
    )
  })

  output$table <- renderTable({SelectedProject()})   


}       


# --- run application ---
shinyApp(ui = ui, server = server)

请注意,如果您的行具有相同的数据,则它们的编号都将相同,并且您将有一个“间隙”,如下所示:(请注意,有两个=1+COUNTIFS(A:A,A2, B:B, "<" & B2) ,一个{ {1}},并没有6

8