奇数项求和公式

Here's an Excel formula challenge for you, based on an email question that someone sent to me. They wanted help with an Excel formula to sum for odd and even weeks. See my solution, and let me know how you'd solve the problem.

根据某人发送给我的电子邮件问题,这是您面临的Excel公式挑战。 他们希望获得有关Excel公式的帮助,以求奇数和偶数周的总和。 查看我的解决方案,让我知道您将如何解决问题。

为什么总和是奇数,甚至是几周? (Why Sum Odd or Even Weeks?)

Have you ever needed to add numbers, based on odd and even numbers in another column?

您是否曾经需要根据另一列中的奇数和偶数来添加数字?

In this example, the person worked in a factory, where there are 2 work crews – Crew A and Crew B. They need to compare the production quantities for the 2 work crews.

在此示例中,此人在一家工厂工作,那里有2名工作人员- 机组A机组B。 他们需要比较两个工作人员的生产数量。

Here's a simplified version of the production data, which we'll use for this challenge. As you can see, the crew name is not in the data.

这是生产数据的简化版本,我们将用它来应对这一挑战。 如您所见,数据中没有机组人员名称。

This is the morning data from the first 4 weeks of the year.

这是一年前4周的早晨数据。

识别机组人员 (Identify the Crews)

Even though the crew name is not listed, we can use the week numbers to identify which crew was working.

即使没有列出机组人员的姓名,我们也可以使用周号来标识正在工作的机组人员。

  • Crew A works mornings on odd-numbered weeks

    机组A奇数周的早晨工作

  • Crew B works mornings on even-numbered weeks

    机组B偶数周的早晨工作

The production data doesn't show the crew name, but we can total the odd or even week data, to get each crew's total quantity.

生产数据没有显示机组人员的姓名,但是我们可以合计奇数或偶数周数据,以获得每个机组人员的总数。

方程式挑战赛 (Formula Challenge)

Your challenge is to create a formula to calculate the total quantities for odd and even weeks

您面临的挑战是创建一个公式来计算奇数周和偶数周的总量

You can type the data in a blank workbook, or download my sample file with the challenge data and all the solutions that are shown below.

您可以在空白工作簿中键入数据,或下载包含挑战数据和下面显示的所有解决方案的示例文件 。

您有什么解决方案? (What's Your Solution?)

You can see my solution in the next section, and below that, you'll see solutions from my weekly Excel newsletter readers.

您可以在下一节中看到我的解决方案,在其下,您将看到每周的Excel新闻快讯读者的解决方案。

What pros and cons can you see in the other people's solutions?

您在其他人的解决方案中可以看到哪些利弊?

If you found a different solution than the ones shown here, let me know in the comment section.

如果您找到的解决方案与此处显示的解决方案不同,请在评论部分告知我。

我的解决方案 (My Solution)

Here's my formula to sum for odd or even weeks. I used the SUMPRODUCT function, combined with ISODD and ISEVEN.

这是我求和奇数或偶数周的公式。 我将SUMPRODUCT函数与ISODD和ISEVEN结合使用。

I put this formula in cell E2, to total the odd weeks:

我将此公式放在单元格E2中,以得出奇数周总数:

  • =SUMPRODUCT((ISODD(--($B$2:$B$11))) *($A$2:$A$11))

    = SUMPRODUCT((ISODD(-($ B $ 2:$ B $ 11)))*($ A $ 2:$ A $ 11))

And here's the formula in cell E3, to total the even weeks:

这是单元格E3中的公式,总共为偶数周:

  • =SUMPRODUCT((ISEVEN(--($B$2:$B$11))) *($A$2:$A$11))

    = SUMPRODUCT((ISEVEN(-($ B $ 2:$ B $ 11)))*($ A $ 2:$ A $ 11))

这个怎么运作 (How It Works)

Here's how my formula works:

这是我的公式的工作原理:

  • The ISODD and ISEVEN functions return TRUE or FALSEISODD和ISEVEN函数返回TRUE或FALSE
  • The two minus signs (double unary) convert those T/F values to numbers (-1 or 0)两个减号(双一进制)将这些T / F值转换为数字(-1或0)
  • Those results are multiplied by the Qty amounts这些结果乘以数量
  • The SUMPRODUCT function returns the total of all those multiplications.SUMPRODUCT函数返回所有这些乘法的总和。

There are more Sumproduct examples on my Contextures website.

我的Contextures网站上有更多Sumproduct示例

其他解决方案 (Other Solutions)

Next, here are some of the formulas that newsletter readers sent to me. You can get the data, and see all of the solutions in the Formula Challenge sample file.

接下来,这是时事通讯读者发送给我的一些公式。 您可以获取数据,并在Formula Challenge示例文件中查看所有解决方案。

MOD功能 (MOD Function)

Many of the solutions used the MOD function, to check if the week numbers were odd or even.

许多解决方案使用MOD功能来检查星期数是奇数还是偶数。

  • The MOD function returns the remainder when you divide the first number (week number) by the second number (2)当您将第一个数字(周数)除以第二个数字(2)时,MOD函数将返回余数
  • If you divide an even number by 2, the remainder will be zero如果将偶数除以2,则余数将为零
  • If you divide an odd number by 2 the remainder will be 1如果将奇数除以2,则余数将为1

For example, to find the total for odd weeks:

例如,要查找奇数周的总数:

=SUMPRODUCT((MOD($B$2:$B$11,2)=1)*$A$2:$A$11)

= SUMPRODUCT(( MOD($ B $ 2:$ B $ 11,2)= 1 )* $ A $ 2:$ A $ 11)

SUM或SUMPRODUCT (SUM or SUMPRODUCT)

All the solutions used SUM or SUMPRODUCT to calculate the grand total.

所有解决方案都使用SUM或SUMPRODUCT来计算总计。

For example, to find the total for even weeks:

例如,要查找偶数周的总数:

=SUM(MOD($B$2:$B$11-1,2)*$A$2:$A$11)

= SUM(MOD($ B $ 2:$ B $ 11-1,2)* $ A $ 2:$ A $ 11)

NOTE: Array Formulas

注意:数组公式

  • In older versions of Excel, you'll need to array-enter the SUM  formulas, with Ctrl+Shift+Enter.

    在旧版Excel中,您需要使用Ctrl + Shift + Enter 数组输入SUM公式

  • If your version of Excel has Dynamic Array formulas, you won't need to do that -- just press Enter.如果您的Excel版本具有动态数组公式,则无需这样做-只需按Enter。

过滤功能 (FILTER Function)

Two of the solutions use the new FILTER function. It filters a set of numbers, based on a rule.

其中两个解决方案使用新的FILTER函数。 它根据规则过滤一组数字。

=SUM(FILTER($A$2:$A$11, MOD($B$2:$B$11,2)))

= SUM( FILTER ($ A $ 2:$ A $ 11,MOD($ B $ 2:$ B $ 11,2)))

In these solutions, the quantities were returned, based on using the MOD function in the week number column.

在这些解决方案中,基于周数列中的MOD函数返回了数量。

You can use these solutions if your version of Excel has Dynamic Array formulas.

如果您的Excel版本具有动态数组公式,则可以使用这些解决方案。

硬编码值 (Hard-Coded Values)

In some solutions, including my original solution, there were hard-coded values. For example, the Odd week formulas used a 1, and the Even week formulas used a zero.

在某些解决方案中,包括我的原始解决方案,都有硬编码的值。 例如,奇数周公式使用1,而偶数周公式使用0。

  • =SUMPRODUCT((MOD($B$2:$B$11,2)=1) *$A$2:$A$11)

    = SUMPRODUCT((MOD($ B $ 2:$ B $ 11,2) = 1 )* $ A $ 2:$ A $ 11)

  • =SUMPRODUCT((MOD($B$2:$B$11,2)=0) *$A$2:$A$11)

    = SUMPRODUCT((MOD($ B $ 2:$ B $ 11,2) = 0 )* $ A $ 2:$ A $ 11)

You could put those values in adjacent cells, and refer to those cells in the formula.

您可以将这些值放在相邻的单元格中,然后在公式中引用这些单元格。

=SUMPRODUCT((MOD($B$2:$B$11,2)=D2)*$A$2:$A$11)

= SUMPRODUCT((MOD($ B $ 2:$ B $ 11,2) = D2 )* $ A $ 2:$ A $ 11)

Then, drag down, to use the same formula in both calculations. I like to use consistent formulas wherever possible!

然后,向下拖动以在两个计算中使用相同的公式。 我喜欢尽可能使用一致的公式!

Here's how I should have written my original solutions, to make it the same in both cells.

这是我应该编写原始解决方案的方式,以使其在两个单元中都相同。

  • In cell D2, type TRUE, and in D3, type FALSE在单元格D2中,键入TRUE,在D3中,键入FALSE
  • In cell E2, enter this formula, then copy it down to cell E3在单元格E2中,输入此公式,然后将其复制到单元格E3中

=SUMPRODUCT((ISODD(--($B$2:$B$11))=D2) * ($A$2:$A$11))

= SUMPRODUCT((ISODD(-($ B $ 2:$ B $ 11))= D2)*($ A $ 2:$ A $ 11))

硬编码阵列 (Hard-Coded Array)

One solution used hard-coded arrays of odd and even numbers.

一种解决方案是使用奇数和偶数的硬编码数组。

  • =SUM(SUMIFS($A$2:$A$11,$B$2:$B$11,{1,3}))

    = SUM(SUMIFS($ A $ 2:$ A $ 11,$ B $ 2:$ B $ 11 , {1,3} ))

  • =SUM(SUMIFS($A$2:$A$11,$B$2:$B$11,{2,4}))

    = SUM(SUMIFS($ A $ 2:$ A $ 11,$ B $ 2:$ B $ 11, {2,4} ))

That worked alright in this small sample, with only 4 work weeks, but you'd need a flexible solution for larger samples.

在这个只有4个工作周的小样本中,这种方法可以正常工作,但是您需要一个灵活的解决方案来处理较大的样本。

助手列 (Helper Columns)

A few people used one or two helper columns in their solutions.  You can see those in the sample file, and I've colour coded the columns, to match the solutions in which they're used.

少数人在解决方案中使用了一两个辅助列。 您可以在示例文件中看到这些内容,并且已经对这些列进行了颜色编码,以匹配使用它们的解决方案。

Helper cells or columns are useful in some situations, allowing you to break a complex formula into smaller sections that are easier to understand or troubleshoot.

辅助单元格或列在某些情况下很有用,可让您将复杂的公式分解为较小的部分,以便于理解或排除故障。

But in these solutions, you'd need formulas in every data row, instead of a just 2 formulas at the top of the worksheet.

但是在这些解决方案中,您需要在每个数据行中使用公式,而不是在工作表顶部仅使用2个公式。

That's not too bad in a small file like this one, but could really slow things down if you're working with thousands of rows of data.

在像这样的小文件中,这还不错,但是如果您要处理成千上万的数据行,则确实可能使速度变慢。

更多总和示例 (More Sum Examples)

There are more How to Sum examples on my Contextures website.

我的Contextures网站上有更多“如何求和”示例

And remember, you can get challenge data, and see all of the solutions in the Formula Challenge sample file.

请记住,您可以获得挑战数据,并在Formula Challenge示例文件中查看所有解决方案。

翻译自: https://contexturesblog.com/archives/2020/04/30/excel-formula-to-sum-for-odd-or-even-weeks/

奇数项求和公式


http://www.taodudu.cc/news/show-5062766.html

相关文章:

  • HbuilderX指定部分区域查找和替换
  • c++string字符串查找和替换
  • python字符串查找和替换
  • Excel中的查找和替换
  • 计算机上的查找替换功能快速格式化,Word2013文档中使用查找和替换功能来快速更改文本格式的方法...
  • centos查找和替换字符串
  • C语言实现字符串的查找和替换
  • php字符串的查找和替换
  • js实现内容查找和替换
  • python字符串之查找与替换_在Python中查找和替换文本
  • word中使用正则表达式进行查找和替换
  • Linux常见的文件内容查找和替换命令
  • string字符串查找和替换
  • Vim查找替换操作 --- 查找和替换
  • 半导体行业的Fabless和IDM两种模式
  • 06什么是Fabless?什么是IDM?
  • 我的世界基岩版json_Editing 基岩版原始JSON文本格式
  • LISP公理——七个原始操作符
  • 【PCA】2D-PCA原始文献《Two-Dimensional PCA》理解
  • 用到的英文词汇转载
  • Review:Microbiota, metagenome, microbiome傻傻分不清
  • 电力系统谐波的产生与危害
  • Awesome-SIEMENS 西门子1847 学习视频整理
  • TN-S TN-C TN-C-S TT IT接地系统的接线图解
  • 数字电路实验怎么接线视频讲解_时间继电器原理,及在星三角启动中的接线原理图...
  • 学习-Python函数之函数定义与调用之四则运算计算器的简单实现
  • java实现四则运算应用(基于控制台)
  • 深入理解VAE(变分自编码器)
  • 控件只读设置
  • java calculator类_Calculator.java

奇数项求和公式_Excel公式求和奇数或偶数周相关推荐

  1. 总离差平方和公式_excel公式怎么用:用EXCEL求离差平方和 和 相关系数

    用EXCEL求离差平方和 和 相关系数 选中浓度和吸两行数据,插入表,XY散点图,下,下一步,完成. 选中散列,图表→添加趋势线,类型:线性,选项:显示公式.显示R平方值,确定. 得到回归方程 y = ...

  2. c# 获取excel单元格公式结果_excel公式应用技巧:文字和数字混合的单元格,如何求和?...

    编按:有些单位部分账目不够规范,譬如报销表,报销内容中文字和金额数据是记录在一起的,怎么求和得到报销金额呢?通常的做法是需要增加一列,把数据单独提取出来,然后进行求和.当然也可以用公式一步到位直接求和 ...

  3. 计算机求和公式IFEROR,excel求和技巧:如何忽略错误值进行求和

    原标题:excel求和技巧:如何忽略错误值进行求和 编按:看似简单的求和,其实是问题的多发地!最近收到小伙伴的留言,"对包含错误值的数据求和该怎么做?要是直接求和,得到的结果也是一个错误值, ...

  4. 如何用公式编辑器打求和符号?

    作为使用最广泛的公式编辑器,MathType中所包含的很多符号能够满足我们一般的学习工作需要,利用它能够毫不费力地编辑出各种各样的数学公式,除了常见的代数几何符号,集合符号以及概率统计等一些符号也有, ...

  5. 包含数字和指定字符的正则表达式_Excel公式练习39: 求字符串中的数字组成的数能够被指定数整除的数的个数...

    学习Excel技术,关注微信公众号: excelperfect 导语:继续研究来自于excelxor.com的案例.这个案例比较复杂,需要仔细研究. 本次的练习是:在单元格A1中输入一个任意长度的字母 ...

  6. 求和符号上下的值怎么打_Excel快速求和的N种方法,一网打尽

    在日常数据统计中,遇到最多的就是数据的求和问题,而且对于绝大部分人来讲,学习Excel是从Sum求和函数开始的. Sum函数,作为资历最老.最简单.最实用的求和函数,是"Excel世界&qu ...

  7. excel如果包含某个字就显示_Excel公式基础知识

    批量输入公式 选取要输入的区域,在编辑栏中输入公式,按CTRL+ENTER即可批量填充公式. 2批量修改公式 如果是修改公式中的相同部分,可以直接用替换功能即可. 3快速查找公式 选取表格区域 - 按 ...

  8. excel减法函数_Excel公式练习35: 拆分连字符分隔的数字并放置在同一列中

    学习Excel技术,关注微信公众号: excelperfect 导语:这个案例仍来自于excelxor.com,没有办法,太有才了,不得不佩服这些人,竟然能把Excel公式与函数玩成这个样子!认真研究 ...

  9. Excel求和只有sum求和?多种高级求和方法都在这里了!

    求和,是Excel最基本的技能,但同时也是最高级的技能.这里有的人会觉得求和不就是sum函数,或者Alt+吗?实际的求和功能远比这些要多得多,例如条件求和,多条件求和...今天就带大家看一下Excel ...

最新文章

  1. 分布式配置管理--百度disconf搭建过程和详细使用
  2. 运用大数据破局“大城市病”有效支撑首都人口疏解
  3. Linux GCC用法
  4. 采样频率和带宽的关系_基于矢量网络分析仪的 TDR 与传统采样示波器 TDR 之间的测量性能和优势比较...
  5. 【BZOJ2243】[SDOI2011]染色 树链剖分+线段树
  6. php ajax加载,php – 什么更快? Ajax加载JSON或Ajax加载完整输出
  7. 10大淘宝直播之城公布:杭州、广州、连云港位列前三
  8. 芯故事 心感动:英特尔企业文化的力量
  9. 剑指offer python版 构建乘积数组
  10. 61.Linux/Unix 系统编程手册(下) -- SOCKET: 高级主题
  11. Adobe软件字体导入无法显示的问题
  12. 难得干货,揭秘支付宝的2维码扫码技术优化实践之路
  13. webservice 缺少根元素_草莓种植,这2种元素至关重要,直接影响草莓的产量和品质...
  14. jquery html() 获取自己
  15. LLVM 编译器学习笔记之三 -- TableGen语言编写*.td文件
  16. 【汇智学堂】基于Socket+面向对象实现的网络聊天
  17. 高防服务器如何防御?
  18. python画图设置坐标轴为科学记数法_防止matplotlib.pyplot中的科学记数法
  19. K8S Runtime CRI OCI contained dockershim 理解
  20. 软件体系结构期末复习

热门文章

  1. PC微信逆向--看看哪些好友删除了自己
  2. 有关宏的编程题(C语言)
  3. JetBrains 发布新款编程字体,提高编程效率、开源免费可商用!
  4. 智能人像自动抠图——C++ 实现LFM 模型推理
  5. C语言超简单入门——基础知识
  6. HDU 1010 Tempter of the Bone heuristic 剪枝法
  7. 摄像头显示与服务器通讯失败,家装摄像头有宽带合手机连接失败是什么原因,手机显示离线前几天还正常?...
  8. DCRNN:扩散卷积递归神经网络
  9. 黑客想要转走你支付宝里的钱会怎样? AlphaRisk 如何对抗 ?
  10. 卷积神经网络工作原理直观的解释?