The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Dear all,
I recently had a problem that was very difficult for me.We urgently need your help.
I have three forms, which are Table 1 Vehicle entry Form, Table 2 Vehicle Inspection Form, and Table 3 Timetable.
My purpose is to create a new column in the vehicle entry form in Table 1 and name it Inspected Vehicles.Determine whether the vehicle has been inspected before entering , and return the inspection time if it is inspected, or return the blank if it is not inspected.
Perform a line-by-line analysis of the vehicle entry form.
For example, in the first row of the vehicle entry form, first check whether the license plate number of the form is in the vehicle inspection form, and if it is not in the vehicle inspection form, it will return blank.
If the number are in the vehicle inspection form, compare the time of this line in the vehicle entry form with the time in the vehicle inspection form, and find the first inspection time in the vehicle inspection form that is earlier than && closest to the time in the vehicle entry form. Otherwise, it returns blank.
Here is my form:
Table 1 Vehicle entry Form
license plate number | entry time |
粤AGR853 | 2024-05-23 12:30:15 |
皖A7Q066 | 2024-05-23 12:29:41 |
粤AAN203 | 2024-05-23 15:49:11 |
皖SH7998 | 2024-05-28 07:38:58 |
粤AM1125 | 2024-05-29 11:52:21 |
粤AAU918 | 2024-05-29 11:45:20 |
粤WN2003 | 2024-05-29 12:49:57 |
粤AKP666 | 2024-05-31 13:01:33 |
粤AAU918 | 2024-06-03 14:01:21 |
皖A7M888 | 2024-06-04 11:23:58 |
皖A7M888 | 2024-06-04 13:00:17 |
粤AFA771 | 2024-06-05 08:56:35 |
皖KV7805 | 2024-06-05 11:54:37 |
粤AAL993 | 2024-06-05 13:53:00 |
粤AGM038 | 2024-06-05 13:58:11 |
粤AFA771 | 2024-06-05 15:34:37 |
粤AFA771 | 2024-06-14 09:58:18 |
粤A85H9F | 2024-06-14 11:23:49 |
皖AD2113 | 2024-06-15 09:57:48 |
皖AD2113 | 2024-06-15 08:50:02 |
粤ABK276 | 2024-06-15 13:18:03 |
粤AFA771 | 2024-06-17 09:36:43 |
粤AFA771 | 2024-06-17 15:49:38 |
粤AJN655 | 2024-06-24 10:17:12 |
粤AAL068 | 2024-05-09 19:13:06 |
鄂E36493 | 2024-06-03 09:16:24 |
豫D97738 | 2024-06-03 12:40:36 |
鄂E36493 | 2024-06-03 17:00:15 |
豫P97738 | 2024-06-03 19:31:22 |
鄂FL5105 | 2024-06-03 09:07:56 |
粤SC7896 | 2024-06-03 10:12:30 |
粤SE8569 | 2024-06-03 08:05:11 |
苏AN4427 | 2024-06-04 11:22:33 |
粤BHY138 | 2024-06-03 20:00:59 |
粤ABE298 | 2024-06-14 21:42:39 |
粤AAL068 | 2024-06-04 15:06:44 |
粤AAL068 | 2024-06-04 23:04:50 |
粤AAU516 | 2024-06-04 16:44:31 |
鄂E36493 | 2024-06-05 08:56:48 |
粤BHY138 | 2024-06-05 09:19:19 |
皖N33046 | 2024-06-14 10:42:38 |
鲁Q395JE | 2024-06-14 09:01:47 |
粤ABC392 | 2024-06-14 11:34:42 |
粤BMP652 | 2024-06-15 12:22:17 |
豫D97738 | 2024-06-15 16:15:23 |
粤BMP652 | 2024-06-15 19:49:53 |
粤ABC392 | 2024-06-15 10:48:53 |
粤SC7896 | 2024-06-15 19:48:08 |
鄂E36493 | 2024-06-16 10:49:19 |
鄂E36493 | 2024-06-16 20:52:37 |
粤SE8569 | 2024-06-16 09:55:04 |
鄂FF7380 | 2024-06-16 19:23:19 |
鄂FF7380 | 2024-06-16 19:11:29 |
粤BHY138 | 2024-06-16 20:42:58 |
粤BMP652 | 2024-06-17 07:46:34 |
豫P97738 | 2024-06-17 13:32:55 |
粤ABK276 | 2024-06-24 14:48:52 |
皖A7S299 | 2024-06-24 16:21:49 |
皖A7S299 | 2024-06-24 14:49:05 |
粤AAL993 | 2024-06-25 10:06:14 |
粤ABK276 | 2024-06-25 10:08:28 |
皖A7J099 | 2024-07-03 14:32:22 |
皖A7J099 | 2024-07-03 14:32:32 |
粤AAU918 | 2024-07-04 11:03:27 |
粤AA33777 | 2024-07-05 22:30:30 |
粤J25Q08 | 2024-07-15 10:37:10 |
皖A7N299 | 2024-07-15 11:10:42 |
皖A7N299 | 2024-07-15 11:10:29 |
粤WN2003 | 2024-07-19 11:32:07 |
粤WN2003 | 2024-07-19 11:17:15 |
鄂L57186 | 2024-07-19 11:42:15 |
鄂L57186 | 2024-07-19 11:42:26 |
粤ABK276 | 2024-07-19 12:28:17 |
粤AFA771 | 2024-07-19 14:50:15 |
粤ABK276 | 2024-07-19 16:05:46 |
粤AJD156 | 2024-07-20 08:55:08 |
粤ABK276 | 2024-07-21 09:38:44 |
粤AAL993 | 2024-07-22 09:33:19 |
粤AAU918 | 2024-07-22 09:48:47 |
粤AFA771 | 2024-07-22 10:48:23 |
粤AD94G1 | 2024-07-22 13:47:08 |
粤BMP652 | 2024-06-17 17:07:15 |
粤SC7896 | 2024-06-17 09:26:43 |
粤SH5599 | 2024-06-17 10:43:59 |
粤SC7896 | 2024-06-17 17:38:36 |
皖N33046 | 2024-06-25 08:29:58 |
粤AAZ707 | 2024-06-25 11:50:12 |
粤ABC392 | 2024-06-24 08:38:24 |
豫P97738 | 2024-06-24 09:58:56 |
鲁Q395JE | 2024-06-24 12:37:29 |
粤BHY138 | 2024-06-24 08:59:36 |
粤BMP652 | 2024-06-25 11:00:35 |
鄂E36493 | 2024-06-25 16:14:05 |
鲁Q395JE | 2024-06-26 07:19:26 |
赣C3178E | 2024-06-25 08:42:51 |
粤BHY138 | 2024-06-25 09:03:54 |
鄂FF7380 | 2024-06-26 06:03:55 |
赣C3178E | 2024-06-26 09:09:49 |
鄂FF7380 | 2024-06-26 06:03:44 |
鄂FF7380 | 2024-06-26 18:14:27 |
鄂FF7380 | 2024-06-26 18:14:18 |
沪D75818 | 2024-07-04 09:35:13 |
沪D75818 | 2024-07-04 16:42:50 |
皖N33046 | 2024-07-05 09:12:40 |
粤ABC392 | 2024-07-04 14:51:18 |
沪D75818 | 2024-07-05 08:44:49 |
豫J76313 | 2024-07-05 13:24:51 |
赣C3882E | 2024-07-05 09:51:46 |
赣C3178E | 2024-07-05 08:48:04 |
鄂FLX789 | 2024-07-05 16:47:33 |
鄂FLX789 | 2024-07-05 16:47:25 |
粤ABC392 | 2024-07-16 10:42:17 |
沪D75818 | 2024-07-19 07:34:53 |
沪ES2758 | 2024-07-19 08:35:54 |
沪D75818 | 2024-07-19 15:56:32 |
沪ES2758 | 2024-07-19 17:34:32 |
粤ABC392 | 2024-07-19 10:53:47 |
粤ABC392 | 2024-07-19 16:03:32 |
沪D75818 | 2024-07-20 11:04:45 |
皖N33046 | 2024-07-22 09:05:06 |
粤ABC392 | 2024-07-20 13:50:37 |
沪D75818 | 2024-07-21 07:49:56 |
赣C3178E | 2024-07-21 09:30:58 |
赣C1303E | 2024-07-21 10:44:44 |
赣C1155E | 2024-07-21 10:05:45 |
粤SE8569 | 2024-07-21 11:27:12 |
沪ES2758 | 2024-07-21 10:48:57 |
沪ES2758 | 2024-07-21 20:56:14 |
沪D75818 | 2024-07-21 19:35:55 |
苏E21216 | 2024-07-21 13:07:05 |
Solved! Go to Solution.
hi @Yumikang ,
you can add additional conditions like:
Table 2: Vehicle inspection form
Inspection time | inspection date | license plate number |
2024/6/6 14:26 | 2024/6/6 | 赣CBM197 |
2024/6/6 14:30 | 2024/6/6 | 粤AS3119 |
2024/6/6 14:32 | 2024/6/6 | 粤A3E96Q |
2024/6/6 14:34 | 2024/6/6 | 粤A5V11T |
2024/6/6 19:30 | 2024/6/6 | 粤SC7896 |
2024/6/7 9:47 | 2024/6/7 | 粤AAU516 |
2024/6/7 9:54 | 2024/6/7 | 粤AAY123 |
2024/6/7 9:57 | 2024/6/7 | 鄂FL5105 |
2024/6/7 15:46 | 2024/6/7 | 粤WN2003 |
2024/6/7 15:51 | 2024/6/7 | 皖N33046 |
2024/6/7 16:00 | 2024/6/7 | 粤A38VN6 |
2024/6/11 12:02 | 2024/6/11 | 粤BHY138 |
2024/6/12 10:13 | 2024/6/12 | 桂P50183 |
2024/6/14 13:21 | 2024/6/14 | 粤ABK276 |
2024/6/14 16:01 | 2024/6/13 | 鲁Q395JE |
2024/6/16 10:28 | 2024/6/16 | 鄂FF7380 |
2024/6/16 14:01 | 2024/6/16 | 粤SE8569 |
2024/6/16 14:03 | 2024/6/16 | 粤SE7753 |
2024/6/24 9:12 | 2024/6/23 | 豫D97738 |
2024/6/24 17:08 | 2024/6/24 | 粤AAL951 |
2024/6/24 17:08 | 2024/6/24 | 粤AAL993 |
2024/6/27 14:26 | 2024/6/29 | 豫J76313 |
2024/6/27 14:26 | 2024/6/29 | 豫JY773 |
2024/7/8 11:06 | 2024/7/8 | 豫J76313 |
2024/7/16 19:42 | 2024/7/16 | 粤AAS759 |
2024/7/18 14:43 | 2024/7/18 | 9.6飞翼 |
2024/7/19 8:50 | 2024/7/19 | 粤AAN203 |
2024/7/19 9:01 | 2024/7/19 | 鄂L57186 |
2024/7/19 15:53 | 2024/7/19 | 粤AJD156 |
2024/7/20 14:17 | 2024/7/20 | 赣C1155E |
2024/7/20 14:19 | 2024/7/20 | 赣C3882E |
Table 3: time form
date |
202401 |
202402 |
202403 |
202404 |
202405 |
202406 |
202407 |
202408 |
202409 |
202410 |
202411 |
202412 |
The relationship I'm trying to model is this
hi @Yumikang ,
In table1, try to add a calculated column like:
column =
MAXX(
FILTER(
table2,
Table2[license plate number]=Table1[license plate number]
&&Table2[Inspection time]<=Table1[entry time]
),
[Inspection time]
)
it is also adivisble to do it in Power Query.
Thanks for your reply.I just tested it.
However, my requirement is that the vehicle needs to be inspected before entrying the park, otherwise it will be blank when the new column is new.However, according to the DAX function, it is also found that the inspection time is later than the admission time, such as the red box in the figure below.
I would like to the new column of time is return to earlier than the time of entry(form1 vehicle entry form-entry time), and it is the closest to the time of entry(form1 vehicle entry form-entry time).
hi @Yumikang ,
i have updated the code in the post as:
column =
MAXX(
FILTER(
table2,
Table2[license plate number]=Table1[license plate number]
&&Table2[Inspection time]<=Table1[entry time]
),
[Inspection time]
)
please try again
Below is screenshot of my latest vehicle entry form.
I found that my measure 2 should be wrong because in the form the car is only checked 1 time, but in my measure 2 it shows 6 times.
And the similar time of entering the park should also be regarded as only one entry, not 6 times.
thank you for your reply.
I would like to know if the recent week before entrying the park has been inspected, so I have added a new column: it is calculated with the datediff function, and the datediff returns the type of week.
Do you have an easier way? I think mine is too cumbersome because I have a lot of new columns.
hi @Yumikang ,
you can add additional conditions like:
thank you very much
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
18 | |
18 | |
17 | |
15 | |
13 |
User | Count |
---|---|
36 | |
35 | |
19 | |
18 | |
18 |