March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello Community,
I have query from SQL server that collecting log from gps the data will update every minute.
the problem is on column D_Name (Driver Name) some rows data are blanks and i would like to fill data ref from earlier rows
based on same Truck ID and Same Date (Due to Driver might change from day to day on the same truck)
how to fill the correct driver name by Power Query Editor
here are sample file
example photo :
Please Advice
Best Regards
JJ
Solved! Go to Solution.
pls try this
let
Source = Excel.Workbook(File.Contents("C:\Users\User\Desktop\SAMPLE.xlsx"), null, true),
Sheet3_Sheet = Source{[Item="Sheet3",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet3_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"V_ID", Int64.Type}, {"V_LICENSE_NO", type text}, {"VLCTL_SMARTCARD_D_CODE", Int64.Type}, {"D_NAME", type text}, {"VLCTL_GPS_DATE", type date}, {"time", type time}, {"VLCTL_ID", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"V_ID", "VLCTL_GPS_DATE"}, {{"Count",
(x) => Table.FillDown(
Table.TransformColumns(x,{"D_NAME",(y)=> if y ="" then null else y}),
{"D_NAME"})
}}),
#"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"Count"}),
#"Expanded Count" = Table.ExpandTableColumn(#"Removed Other Columns", "Count", {"V_ID", "V_LICENSE_NO", "VLCTL_SMARTCARD_D_CODE", "D_NAME", "VLCTL_GPS_DATE", "time", "VLCTL_ID"}, {"V_ID", "V_LICENSE_NO", "VLCTL_SMARTCARD_D_CODE", "D_NAME", "VLCTL_GPS_DATE", "time", "VLCTL_ID"})
in
#"Expanded Count"
@Ahmedx ,
The result is correct. Thank you very much. but I dot know How to apply with the actual file. due to it work with advance editor and i dont have exp. on this. Would you mind checking another(actual) file and how to solve the same problem. Thank you in advance.
Sample 2 flie.
Sample2
Best Regards,
JJ
Update I followed your step and it work.
some rows still blank which mean there is no D_Name Data for the whole day so it shown as blank is that correct?
I think so, or show me where to get the data for these lines. if according to ID and date it is the first day.
OK. I think this is fine, Thank you very much
Thank you I will try follow your step with the actual data. I will update later .
look at the screenshot and tell me what should be in the D_NAME column?
Yes sir, The answer should be MR TONY SIN
the logic is lookup from latest row that has D_Name based on same V_ID (License NO) and Same GPS_Date
will that be right?
post this file too
C:\Users\008098\Desktop\SAMPLE.xlsx
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |