excel - 有什么方法可以在 PowerQuery 中移动“单元格”?
问题描述
我有多个需要分析的 CSV 文件,在顶行中有两条识别信息。下面的下一行是空白的。第三行包含标题。如何创建 2 个自定义列,其中包含从顶行向下复制到下面所有 100 多行数据的“单元格”4 和 6?Excel VBA 很简单,但是这个数据集将被永久使用,以后的用户可能不会懂 VBA。(感谢亚历克西斯的桌子!!)
| Probe | 503 | SN:1256 | 8/27/2020 | 13:23 | AUG20 | BH02 |
|-------|---------|---------|-----------|-------|--------|----------|
| | | | | | | |
| Tube# | Tube ID | MC # | A B Cal | Units | STD MC | Ratio |
| 1 | 8 | 1 | | | | |
| 1 | 1 | -1 | Count | 7403 | 1493 | 0.201675 |
| 2 | 1 | -1 | Count | 7403 | 1486 | 0.200729 |
| 3 | 1 | -1 | Count | 7403 | 1686 | 0.227746 |
| 4 | 1 | -1 | Count | 7403 | 1705 | 0.230312 |
| 5 | 1 | -1 | Count | 7403 | 1779 | 0.240308 |
| 6 | 1 | -1 | Count | 7403 | 1954 | 0.263947 |
| 7 | 1 | -1 | Count | 7403 | 1965 | 0.265433 |
解决方案
发布样本数据。
像这样的东西,假设没有列标题开始,会拉出第一行,并转换为剩余数据的列
// get the first two columns of first row
TopRow1 = Table.First(#"PreviousStep")[Column1],
TopRow2 = Table.First(#"PreviousStep")[Column2],
// remove first row
#"Removed Top Rows" = Table.Skip(#"PreviousStep",1),
// convert new first row to column headers
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
// custom columns to add the data we found above
#"Added Custom" = Table.AddColumn(#"Promoted Headers", "TopRow1", each TopRow1),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "TopRow2", each TopRow2)
推荐阅读
- scikit-learn - 如何在有条件和限制的情况下进行预测?
- c# - Gitlab API:单元测试问题、项目和登录问题
- mysql - 编写视图以将具有两列的表转换为具有多列
- uwp - UWP:InAppNotification 未显示
- java - 爪哇。如何防止将方法引用分配给功能接口类型参数?
- validation - 根据数据在 Google 表格中添加自动填充选项
- simulink - MATLAB C S-Function不能在simulink实时编译
- tensorflow - 如何在每批之后获取一个时期的历史
- javascript - 有没有更简单的方法或不同的方法可以在 JavaScript 中处理这个标志验证?
- c - 将静态库 czmq 添加到 C 项目 (CMake)