Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a date table with the following columns
Date, LatestReportDate, 5YearsPreLatestreportdate
01/01/2014 01/01/2019 01/01/2014
02/01/2014 01/01/2019 01/01/2014
03/01/2014 01/01/2019 01/01/2014
I want to create a conditional Column, where Date Between LatestreportDate and 5yearsLatestReportDate Then True
Else False
But Im struggling with the syntax
If anyone could pop me across the proper syntax for M. That would be great
Solved! Go to Solution.
Hello @DebbieE
Place the following M code in a blank query to see the steps. The last step is the important one:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDWNzDUNzIwNFbSUQKyIBxLZI6JUqxONDKXgEIjYhTGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, LatestReportDate = _t, #"5YearsPreLatestreportdate" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"LatestReportDate", type date}, {"5YearsPreLatestreportdate", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Date] <= [LatestReportDate] and [Date] >= [5YearsPreLatestreportdate] then true else false)
in
#"Added Custom"
Please mark the resolved question when you are finished and consider giving a thumbs up if the posts are useful.
Contact me privately for assistance with any large-scale BI needs, tutoring, etc.
Bless you
Thanks so much. Worked a treat
Hello @DebbieE
Place the following M code in a blank query to see the steps. The last step is the important one:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDWNzDUNzIwNFbSUQKyIBxLZI6JUqxONDKXgEIjYhTGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, LatestReportDate = _t, #"5YearsPreLatestreportdate" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"LatestReportDate", type date}, {"5YearsPreLatestreportdate", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Date] <= [LatestReportDate] and [Date] >= [5YearsPreLatestreportdate] then true else false)
in
#"Added Custom"
Please mark the resolved question when you are finished and consider giving a thumbs up if the posts are useful.
Contact me privately for assistance with any large-scale BI needs, tutoring, etc.
Bless you
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 58 | |
| 43 | |
| 41 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 121 | |
| 96 | |
| 65 | |
| 46 |