Forum Discussion
Anonymous
2 years agoNot applicable
[Revised]Need Help Create Scoring and penalty system
Hello, i revised my question so it easier to understand I want to create scoring logic 1) Every single day Driver have 100 point 2) in a ROW of the same driver name same DATE ...
- 2 years ago
This is a sample m query which you can refer.
You can try by creating a separate table in query editor by referencing Vehicle_location_log_2023 table.
let Source = Vehicle_location, #"Grouped Rows" = Table.Group(Source, {"V_License_no", "GPS_DATE", "MT_Name"}, {{"Count", each Table.RowCount(_), Int64.Type}}), #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"MT_Name"}, #"Score Master", {"MT_Name"}, "Score Master", JoinKind.LeftOuter), #"Expanded Score Master" = Table.ExpandTableColumn(#"Merged Queries", "Score Master", {"Penalty", "Celing"}, {"Score Master.Penalty", "Score Master.Celing"}), #"Added Custom" = Table.AddColumn(#"Expanded Score Master", "is_full_panalty", each [Score Master.Celing] < [Count]), #"Added Conditional Column" = Table.AddColumn(#"Added Custom", "Final Panalty", each if [is_full_panalty] = true then 100 else [Score Master.Penalty] * [Count]), #"Grouped Rows1" = Table.Group(#"Added Conditional Column", {"V_License_no", "GPS_DATE"}, {{"Sum of Panalty", each List.Sum([Final Panalty]), type nullable number}}), #"Added Conditional Column1" = Table.AddColumn(#"Grouped Rows1", "Final Panalty", each if [Sum of Panalty] > 100 then 100 else [Sum of Panalty]), #"Changed Type" = Table.TransformColumnTypes(#"Added Conditional Column1",{{"Final Panalty", type number}}) in #"Changed Type"After creating the table, you can refer column from this table.
Nilupul
2 years agoFrequent Visitor
This is a sample m query which you can refer.
You can try by creating a separate table in query editor by referencing Vehicle_location_log_2023 table.
let
Source = Vehicle_location,
#"Grouped Rows" = Table.Group(Source, {"V_License_no", "GPS_DATE", "MT_Name"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
#"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"MT_Name"}, #"Score Master", {"MT_Name"}, "Score Master", JoinKind.LeftOuter),
#"Expanded Score Master" = Table.ExpandTableColumn(#"Merged Queries", "Score Master", {"Penalty", "Celing"}, {"Score Master.Penalty", "Score Master.Celing"}),
#"Added Custom" = Table.AddColumn(#"Expanded Score Master", "is_full_panalty", each [Score Master.Celing] < [Count]),
#"Added Conditional Column" = Table.AddColumn(#"Added Custom", "Final Panalty", each if [is_full_panalty] = true then 100 else [Score Master.Penalty] * [Count]),
#"Grouped Rows1" = Table.Group(#"Added Conditional Column", {"V_License_no", "GPS_DATE"}, {{"Sum of Panalty", each List.Sum([Final Panalty]), type nullable number}}),
#"Added Conditional Column1" = Table.AddColumn(#"Grouped Rows1", "Final Panalty", each if [Sum of Panalty] > 100 then 100 else [Sum of Panalty]),
#"Changed Type" = Table.TransformColumnTypes(#"Added Conditional Column1",{{"Final Panalty", type number}})
in
#"Changed Type"
After creating the table, you can refer column from this table.