Excel - 如果向经理报告的次数少于5次,则进行迭代和组计数

时间:2016-05-19 11:59:27

标签: excel grouping

在Excel中给出了员工和经理的数据集,例如

Staff Name              Manager
Employee 1              Adam Francis
Employee 2              Adam Francis
Employee 3              Adam Francis
Employee 4              Adam Francis
Employee 5              Adam Francis
Employee 6              Adam Francis
Employee 7              Adam Francis
Employee 8              Adam Francis
Employee 9              Adam Francis
Employee 10             Adam Francis
Employee 11             Adam Francis
Employee 12             Adam Francis
Employee 13             Adam Francis
Employee 14             Adam Francis
Employee 15             Adam Francis
Employee 16             Alexander Hammersley
Employee 17             Alexander Hammersley
Employee 18             Alexander Hammersley
Alexander Hammersley    Caulton Rose
Caulton Rose            Bob Fisher
Adam Francis            Bob Fisher
Employee 21             Mary Bond
Employee 22             Mary Bond
Employee 23             Mary Bond
Employee 24             Mary Bond
Employee 25             Mary Bond
Employee 26             Mary Bond
Mary Bond               Bob Fisher

如何汇总数据,以便如果报告人员计算< 5汇总到下一个直线经理,一旦达到5,它就不应该再累积?

这样就可以输出

Manager       Staff Count
Adam Francis  15
Mary Bond     6
Bob Fisher    7 

鲍勃拥有所有亚历克斯,卡尔顿和他们的工作人员,但亚当(因为亚当没有向自己报告!)和玛丽

以下psuedologic的内容。

Loop until finished {
If Parent.Children >=5 then GrandParent has only Parent as report && Parent named as result with child count.
elseIf Parent.Children <5 GrandParent = Parent.children + Parent  
Grandparent = Parent
Parent = Child

}

0 个答案:

没有答案