Forum Discussion
If 2nd Date/Time Row, Remove Both
Hi Anonymous
Try this:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZBLCsMwDAWvErwORF9L8h0K3Yfc/xqRU7qp1ZXgMYOkd55NhR3N2t7CgTmnHoQHAcFGA21IbO/XjKld+5f3DJDBmFZBeyHEI4hD/xV8QCE4ZGDdQlcepeBxLgAGLYScqzAvD+sCBV8dNKvB/LkvL/tgLQT506lEtvThMVK4bg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [chkinid = _t, memid = _t, checkin = _t, stationid = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"chkinid", Int64.Type}, {"memid", Int64.Type}, {"checkin", type text}, {"stationid", Int64.Type}}),
whos_checkedout_ = Table.SelectRows(#"Changed Type",each [stationid] = 192 )[memid],
final_ = Table.SelectRows(#"Changed Type",each not List.Contains(whos_checkedout_,[memid]) )
in
final_
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs
Cheers
Thanks for this... some weirdness, though (and both methods got the exact same results):
- It's not removing all people who have scanned at check-out stationid 192 (see memid 76795). It did remove memid 98033 who checked out.
- The checkin date from the query doesn't match when they actually scanned in.
- The stationid from the query doesn't match the stationid that they actually scanned in on.
- It's also not picking up any scans from memid 104958.
In the below data, I've included checkin and stationid from both the query and the table for comparision. The table names are in all caps in each column heading.
Also - I apologize for not mentioning this earlier, but stationid 56 is a secondary check in station within the facility and should not be counted as a check out when it occurs after initially scanning at stationid 52 upon entry. Stationid 187 is an alternate initial entry to the building and should be treated the same as stationid 52.
| CHKINS checkin | QUERY1 checkin | QUERY1 chkinid | QUERY1 memid | STATIONS stationid | QUERY1 stationid | STATIONS stationname |
| 5/25/2020 7:52:39 AM | 5/21/2020 2:18:26 PM | 5438182 | 97640 | 187 | 52 | Ground Level Entry |
| 5/25/2020 12:08:48 PM | 5/21/2020 2:18:06 PM | 5438179 | 134806 | 52 | 52 | Main Check In |
| 5/25/2020 12:08:56 PM | 5/21/2020 2:18:14 PM | 5438180 | 76795 | 52 | 52 | Main Check In |
| 5/25/2020 12:09:09 PM | 5/21/2020 2:18:20 PM | 5438181 | 103055 | 52 | 52 | Main Check In |
| 5/25/2020 12:59:05 PM | 5/21/2020 2:18:06 PM | 5438179 | 134806 | 56 | 52 | Health & Wellness Check In |
| 5/25/2020 1:12:59 PM | 5/21/2020 2:18:14 PM | 5438180 | 76795 | 192 | 52 | Member Check-Out |