Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Otto_Luvpuppy
Helper II
Helper II

Between Two Dates

Hi, I'm creating a Custom Column with some 'if else' bits going on. I'm nearly there but can't quite get the final piece.
I need to select a particular line if it's date is bewteen two dates...one of them fixed (01/01/1900) and the other from another date in the same row. BewteenDates doesn't work as I guess it's DAX not M. Any ideas please?

 

Here's a bit of the statement:

if [#"Anticipated Date of Completion / Return"] > Date.FromText("01/01/1900") and [#"Anticipated Date of Completion / Return"] < [Max Date] then "Overdue" else "blah blah blah"

 

Thanks

1 ACCEPTED SOLUTION

@Otto_Luvpuppy - Well, error messages always help. So the biggest issue I see is that it looks like you are referring to a step as if it is a column but it is hard to tell. Try this query out and see how it matches up with yours:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtM30jcyMDJQ0gEyTSDMWJ1oBAckbowsbo4Qt0AWNzRASFhCJWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date of Return" = _t, #"Max Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date of Return", type date}, {"Max Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Date of Return] > Date.FromText("1/1/1900") and [Date of Return] < [Max Date] then "Overdue" else "Not")
in
    #"Added Custom"

 

You can just create a blank query and then paste in this code, completely replacing the existing code in Advanced Editor.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@Otto_Luvpuppy - So what is the issue?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

um......it doesn't work Greg.

Are you saying that what I have should work? If so I've probably got a bigger problem. 🤔

 

Thanks

@Otto_Luvpuppy - Well, error messages always help. So the biggest issue I see is that it looks like you are referring to a step as if it is a column but it is hard to tell. Try this query out and see how it matches up with yours:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtM30jcyMDJQ0gEyTSDMWJ1oBAckbowsbo4Qt0AWNzRASFhCJWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date of Return" = _t, #"Max Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date of Return", type date}, {"Max Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Date of Return] > Date.FromText("1/1/1900") and [Date of Return] < [Max Date] then "Overdue" else "Not")
in
    #"Added Custom"

 

You can just create a blank query and then paste in this code, completely replacing the existing code in Advanced Editor.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks.....I'll give it a whirl....actually I'm not getting any error messages just empty cells where there shouldn't be....so part of my code is working fine.

 

Thanks again for your help.

Hi @Otto_Luvpuppy ,

 

Or you can create a calculated column by:

 

Column =  IF( [#"Anticipated Date of Completion / Return"] >DATE(1900,1,1) && [#"Anticipated Date of Completion / Return"] <EARLIER([Max Date]), "Overdue","....")

 

Best Regards,

Dedmon Dai

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors