Hi @Tanzeel,
See if this meets your requirement.
First the GradeList query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("LY9JDoMwEAT/4mswMvEy5AhE+YTl/38jU605dAtVUyOYM5W0pfrx+nmKsraZGo8N/vUcCrzDe/N6MnC3aI2dEenxvBX4QBqSXsC9RmtEGkh3FrZoRsM0zJvvVMSRTBIXqy7WuHginUhXFrZojZhH4ZWLX1TW+gM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Min = _t, Max = _t, Grade = _t, GPA = _t, #"Grade Point" = _t]),
ChType = Table.TransformColumnTypes(Source,{{"GPA", type number}, {"Grade Point", type number}, {"Min", Int64.Type}, {"Max", Int64.Type}}),
AddGetFields = Table.AddColumn(ChType, "GetFields", each [ Grade = [Grade], GPA = [GPA]])
in
AddGetFields
.
and second the Grades query
let
MarkList = List.Buffer( GradeList[Max] ),
RecList = List.Buffer( GradeList[GetFields] ),
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bVZLliQhCLxLrrv7pUD6OcAs+wT96v7XmBJEA62NWUWI/AL07+9K9fv333e6vi563gvTT/80XRN18f1zAHLAqpzkvZSFSV9S0V0dadfryy1m1WJTbn1fMsUEh4Kcd+yx7eYKL10Z5+hS9Xd5wLAqz3jTDaZbkNKOkMfF4Fa2DSqq7yX3+Jc1Kn6m/urn1OmASyRIaZ1owVWNSmUYc8Z0PrzCpbKyMQqZN3Gocp5hj3IAyBXsqtUc4nuypsf23njq7RpBLBtI2XkDCBcXjohyC0ZzWUY9XSl8TkQOfJyt4QtU1HwbdTfzaDwZqc04OF3BMojNiXq6ZR+aIIvTy+t7RybdQH5eBka6yyZmrIWCI3SedkfVntWwmovMwa6U5TQtdwsmCOS8Y2lr4hKsBqe2iEUmOxNGA60QADpgs00RG3y0gM2NpyK7GgRW5olD69nkcmK0iu1EgAqPwAex0XDJs1aEetAtQU4BczrbFpk8SItRk1hotH2mc0MNBPgALeEb55igDEqrFIpbVVU5/WBQDRIZADlgmEo0IM4rBSmfzdvIWcFxYNByNCK8oVZ5wZlCY1LCJr3uJATcFpqhtnEaAMKfcC2reO2HYXTxw8BqerX0TWRo/1+RhSAXHFcDRVoBLPeRunAlJZt/5EcU7GE4ukC4EVVieZP5tIKimWaWYBSoQXnRtuC8QIAOcA5igkknmOUObhd9SnATara9wmlxEeW8YzjWHOOQ4U/hVmiIOlsEbm2Q0obIctCfIDxox4vlOQWDbdIY7/LblfZRAQg8bObo8mabL8XtDkj2ABl3y+0BJMzIFNMBzRFybS8ADtPSLOMsTjJrQt4bGnlFCQdppOu1Hod4qfP1ev0H", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [RegNo = _t, #"CLO-2" = _t, #"CLO-1" = _t, #"CLO-4" = _t, #"CLO-3" = _t, #"PLO-4" = _t, #"PLO-1" = _t, #"PLO-5" = _t, #"PLO-3" = _t, #"PLO-2" = _t, P2 = _t, C1 = _t, C3 = _t, C2 = _t, C4 = _t, #"Final-Exam" = _t, Sessional = _t, #"Mid-Exam" = _t, TotalMarks = _t]),
ChType = Table.TransformColumnTypes(Source,{{"CLO-2", type number}, {"CLO-1", type number}, {"CLO-4", type number}, {"CLO-3", type number}, {"PLO-4", type number}, {"PLO-1", type number}, {"PLO-5", type number}, {"PLO-3", type number}, {"PLO-2", type number}, {"P2", type number}, {"C1", type number}, {"C3", type number}, {"C2", type number}, {"C4", type number}, {"Final-Exam", type number}, {"Sessional", type number}, {"Mid-Exam", type number}, {"TotalMarks", type number}}),
GetRecord = Table.AddColumn(ChType, "Temp", each
let
Mark = [TotalMarks],
GradeKey = List.RemoveNulls( List.Transform( MarkList, each if Mark <= _ then _ else null )){0},
Position = List.PositionOf( MarkList, GradeKey ),
GetRecord = RecList{Position}
in
GetRecord
),
ExpandRecord = Table.ExpandRecordColumn(GetRecord, "Temp", {"Grade", "GPA"}, {"Grade", "GPA"})
in
ExpandRecord
.
Sample of the result
Here’s your sample file.
eDNA Grades.pbix (53.2 KB)
I hope this is helpful