excel - 用于检查 COG 是否在边界框中的 PowerQuery 公式
问题描述
我正在尝试定义对象的齿轮在哪个框中。例如,我有一个带有 COG (1.2, 1.5, 0.3) (x, y, z) 的项目和一个框列表:
箱数 | Z 低 | Z高 | Y 离开 | 对 | X前 | X 船尾 |
---|---|---|---|---|---|---|
1 | 0 | 3 | -5 | 0 | 5 | 0 |
2 | 0 | 3 | 0 | 5 | 5 | 0 |
在此示例中,该项目位于框 2 中。我现在的解决方案是使用 Sumifs,如果 COG 低于/高于边界值,则检查每个边界,因为框没有重叠。
大多数数据都是用 powerquery 加载的,但我不能让这个 sumifs 语句在 powerquery 中工作,我必须将数据加载到 excel 并添加 sumifs 语句,如果我想在 Power BI 中加载它,这将不起作用。否则我必须打开 excel,在那里刷新并让计算运行,保存,打开 PBI 并在那里刷新。
是否可以使用 sumifs 或仅使用 Power BI 的其他解决方案来做出此声明?
解决方案
您可以只比较x,y,z
参数并输出通过测试的框号列表。
例如:(作为函数)
(x as number, y as number, z as number) =>
let
Box = Table.FromRecords({
[Box Number=1, Z Low=0, Z High=3,Y Left=-5,Y Right=0,X Front=5,X Aft=0],
[Box Number=2,Z Low = 0, Z High=3, Y Left=0, Y Right=5,X Front=5,X Aft=0]
}),
typeIt = Table.TransformColumnTypes(
Box, List.Transform(Table.ColumnNames(Box), each {_,Int64.Type})
),
inOut = Table.AddColumn(typeIt,"ckBox", each
x >= [X Aft] and x<= [X Front] and
y >= [Y Left] and y <= [Y Right] and
z >= [Z Low] and z <= [Z High]
),
boxNum = Table.SelectRows(inOut,each [ckBox] = true)
in
boxNum[Box Number]
推荐阅读
- sql - 是否可以在所有 Redshift 程序中搜索文本?
- python-3.x - 有人能告诉我在大整数上执行 SHA-256 时我做错了什么(使用 python 的 hashlib)吗?
- c - C 警告:对位运算无效的语句
- flutter - 如何在颤动中将项目作为水平滚动而不是垂直列表视图构建器进行分页?
- php - PHP - 如何绕过具有 2 个值的变量?
- piranha-cms - Piranha CMS 中的反序列化媒体字段失败
- django - 如何通过request.path检查包含参数的路径?
- node.js - 创建 CSV 或 PDF 文件而不将其保存到光盘并将其流式传输到 AWS S3 Bucket
- python - 类型错误:ID 为“Br(None)”的 `dash_html_components.P` 组件(版本 1.0.3)检测到 `children` 以外的道具的组件
- android - 当按下 menuItem 以在 android 中显示用于列表视图的自定义适配器时,应用程序崩溃