Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I have two date columns - Date A and Date B.
How can I check if Date A is within 7 days before any of Date B?
Solved! Go to Solution.
Copy the below code and paste it into the advance editor.
let
TableA = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fY9LDoAgDETv0rUJ7YCCZ2m4/zXEFZ2auHzJfN3FatFRoGgyDxdchIvuTbawbxwktVZMA3a2DrKCWw08wj7iGFWpKC1+vUGMzlEnYVrFh6r+PkjBYHE4NB8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable date) meta [Serialized.Text = true]) in type table [Date = _t]),
TableAChangedType = Table.TransformColumnTypes(TableA,{{"Date", type date}}),
TableB = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtc3sNQ3MjAyUYrViVYyNEbhmqHwTPQNDRA8CxQ5I6A5FriUGhugqDVHkTSyROiMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable date) meta [Serialized.Text = true]) in type table [Date = _t]),
TableBChangedType = Table.TransformColumnTypes(TableB,{{"Date", type date}}),
Custom1 = Table.AddColumn(TableAChangedType, "Flag", each not Table.IsEmpty(Table.SelectRows(TableBChangedType, (x)=> x[Date]>=[Date] and Date.AddDays(x[Date],-7)<=[Date])))
in
Custom1
I have added a new column into Table A with true value for the rows which are with in the 7 days of at least a date in Table B
Hi,
Thanks for the solutions @Omid_Motamedise and @jgeddes offered, and i want to offer some more information for user to refer to.
hello @stan255 , baded on your picture, your two date columns come from different tables, in table A , you can create a cusotm column.
let a=Query2[reportedDate],
b=[Open],
c=List.Count(List.Select(a,each b>=Date.AddDays(_,-7) and b<=_))
in if c>0 then "Y" else "N"
Output
You can refer to the attachment.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Copy the below code and paste it into the advance editor.
let
TableA = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fY9LDoAgDETv0rUJ7YCCZ2m4/zXEFZ2auHzJfN3FatFRoGgyDxdchIvuTbawbxwktVZMA3a2DrKCWw08wj7iGFWpKC1+vUGMzlEnYVrFh6r+PkjBYHE4NB8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable date) meta [Serialized.Text = true]) in type table [Date = _t]),
TableAChangedType = Table.TransformColumnTypes(TableA,{{"Date", type date}}),
TableB = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtc3sNQ3MjAyUYrViVYyNEbhmqHwTPQNDRA8CxQ5I6A5FriUGhugqDVHkTSyROiMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable date) meta [Serialized.Text = true]) in type table [Date = _t]),
TableBChangedType = Table.TransformColumnTypes(TableB,{{"Date", type date}}),
Custom1 = Table.AddColumn(TableAChangedType, "Flag", each not Table.IsEmpty(Table.SelectRows(TableBChangedType, (x)=> x[Date]>=[Date] and Date.AddDays(x[Date],-7)<=[Date])))
in
Custom1
I have added a new column into Table A with true value for the rows which are with in the 7 days of at least a date in Table B
Something like this might work for you...
Proud to be a Super User! | |
Thanks for this solution. I'm getting this error
"DataFormat.Error: We couldn't convert to Date.
Details:
[List]"
Hi,
Thanks for the solutions @Omid_Motamedise and @jgeddes offered, and i want to offer some more information for user to refer to.
hello @stan255 , baded on your picture, your two date columns come from different tables, in table A , you can create a cusotm column.
let a=Query2[reportedDate],
b=[Open],
c=List.Count(List.Select(a,each b>=Date.AddDays(_,-7) and b<=_))
in if c>0 then "Y" else "N"
Output
You can refer to the attachment.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
25 | |
12 | |
12 | |
11 | |
8 |
User | Count |
---|---|
42 | |
27 | |
14 | |
13 | |
13 |