excel - 比较两个表并显示缺失的数据 - Power BI
问题描述
我有数百条线路,其中包含我的员工在这一年中学习的不同课程。而且我还有一张表,上面有他们必须参加的必修课……我想找到一种方法来比较这两张表,看看缺少哪些课程。如果有人帮我提供执行“完成栏”的想法,我也将不胜感激(例如:员工 1:参加了 78% 的课程)
为了说明我拥有的数据:
表 1(2021 年培训)
布鲁诺 | 课程 A
布鲁诺 | 课程 B
表 2(2021 年强制性培训)
课程 A
课程 B
课程 C
期望的输出(缺少的课程):
布鲁诺 | 课程 C
非常感谢。
解决方案
查看代码中的注释,并探索 Applied Steps 窗口,以了解算法
M代码
let
Training2021= Table.FromRecords(
{[Name="Bruno", Course="Course A"],
[Name="Bruno", Course="Course B"],
[Name="George",Course="Course A"],
[Name="George",Course="Course C"],
[Name="Sandra",Course="Course C"]},
type table [Name=Text.Type, Course=Text.Type]),
MandatoryTraining2021= Table.FromRecords(
{[Course="Course A"],
[Course="Course B"],
[Course="Course C"]},
type table[Course=Text.Type]),
//group training table by Name
group = Table.Group(Training2021,"Name",
{"Courses", each [Course]}
),
//Missing courses using List.RemoveMatchingItems
#"Added Custom" = Table.AddColumn(group, "Missed", each
Text.Combine(
List.RemoveMatchingItems(
MandatoryTraining2021[Course],[Courses]),"; "), type text),
//Percent Completed
#"Added Custom1" = Table.AddColumn(#"Added Custom", "% Taken", each
List.Count([Courses])/Table.RowCount(MandatoryTraining2021),Percentage.Type),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Courses"})
in
#"Removed Columns"
推荐阅读
- android - 如何在 Android 中创建 object.getClass() 方法的新对象?
- html - 无法嵌入 YouTube 以在我的网站上加载视频(按频道最新上传)
- java - 使用递归理解乘法
- laravel - Laravel 数据库通知未发送
- r - R - 如何在循环中改变一个函数来计算给定的单词并为每个单词添加一个新列
- rust - 是否可以匹配 clap 的 ArgMatches 类型?
- javascript - 是否可以破解 javascript 界面?
- raspberry-pi - libcurl4-openssl-dev :冲突:libssl1.0-dev 但要安装 1.0.2q-2
- c# - 在我的 Web api 端点中解析 HTTP POST 请求正文时出错
- python - passing optional arguments to a function in pandas