我有數百條線路,我的員工在這一年里參加了不同的課程。而且我還有另一個表格,上面列出了他們必須參加的必修課程......我想找到一種方法來比較這兩個表格,看看缺少哪些課程。如果有人幫助我給我提供執行“完成欄”的想法,我也將不勝感激(例如:員工 1:參加了 78% 的課程)
為了說明我擁有的資料:
表 1(2021 年培訓)
布魯諾 | 課程 A
布魯諾 | 課程B
表 2(2021 年強制性培訓)
課程 A
課程 B
課程 C
期望輸出(缺少課程):
布魯諾 | 課程C
非常感謝。
uj5u.com熱心網友回復:
查看代碼中的注釋,并瀏覽應用步驟視窗,以了解演算法
培訓2021

強制性培訓2021

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"
結果

uj5u.com熱心網友回復:
請檢查此解決方案

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/313367.html
