如何将列表A中一列的所有项与条件相加,然后将总和值保存到列表B. [英] How to sum all items from one column in list A with condition's and then save sum value to list B

查看:63
本文介绍了如何将列表A中一列的所有项与条件相加,然后将总和值保存到列表B.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有挑战;对列表A中一列中的所有值求和,当此列表中的另一列符合特定条件时,将该总和保存到列表B,以匹配匹配的标题字段。还要重新计算新项目添加到列表
A时的总和(而不是仅仅添加新值,因为条件可能已更改)


如果还没有总和如果列表B中的项目具有匹配的标题,它将更新总和字段而不是创建另一个项目。 >

因此,在列表A中可能有数百个具有相同标题的项目,但在列表B中,每个唯一标题将有一个项目,它将列出所有列表A的值列。


我的第一个想法是工作流程,但我无法找到所有项目的总和,更不用说添加标准了。 


有没有人有任何想法我怎么能做这个?  非常感谢任何帮助。




解决方案

https://www.youtube.com/watch?v=j4CU5UwtOBo



我制作了一个关于如何使用循环和词典的视频,这就是你想要做的事情(看看我搞砸的区域的笔记部分)。



基本上,你想要的循环通过A来总结所有相似的项目。然后你循环通过B寻找匹配的标题。如果你找到它,那么就有一个像"找到"这样的变量。更新为true,然后您可以只执行更新项目,其中标题A =标题B并更改
sum列。如果在循环结束时"找到",是假的,那么你只需创建一个带有标题的新项目,然后将总和设置为你的A和。



另一种选择是循环通过A,如果你没有找到任何其他项目(意味着你当前的项目总和仍然是总和),那么你可以假设B中没有项目,所以你运行创建项目选项,否则运行更新


Hello everyone, I have a challenge to; sum all values in one column in list A, when another column in this list meets certain criteria, then save that sum to list B against a matching Title field. also to recalculate the sum when new items are added to list A (rather than just add the new value as the criteria might have changed)

If a sum hasn't been made before it will make a new item in List B with the same title as the title in list A. if there is an item in list B that has a matching title it will update the sum field rather than create another item.

So in List A there may be hundreds of items with the same title, but in List B there will be one item per unique title which sums all of List A's value columns.

My first thought was a workflow but i cannot find away to sum all items let alone then add criteria to the sum. 

Has anyone got any ideas how i can do this?  Any help would be much appreciated.


解决方案

https://www.youtube.com/watch?v=j4CU5UwtOBo

I made a video on how to use Loops and Dictionaries, which is what you want to do here (look at the notes section for an area where I messed up).

Essentially, you want to loop through A to sum all the like items. Then you loop through B looking for a matching title. If you find it, then have a variable like "found" update to true, then you can just do an update item where title A = title B and change the sum column. If at the end of the loop "found" is false, then you just create a new item with the title and then set the sum to your A sum.

Another option is to loop through A and if you don't find any other items (meaning your current item sum is still the sum), then you can assume that there isn't an item in B, so you run the create item option, otherwise run the update.


这篇关于如何将列表A中一列的所有项与条件相加,然后将总和值保存到列表B.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆