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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Delguy87
Frequent Visitor

Need Help fixing datediff. Seeing 'same day' and 'BLANK' data(for one of the day) as same results.

I'm creating a report for Trouble Tickets. I have 2 columns representing 'Date Created' and 'Date Completed'. The resulting Column('# of Days to Clear 2') from _datediff generates my results but I'm getting tickets closed on the same day and Tickets that do not have a value under 'Date completed' as 'remaining open'.  How do I get same-day closed tickets to be a part of the 'Cleared in 7 days or less' .

see below:

Delguy87_0-1710166891569.jpeg

 

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@Delguy87 Instead of DATEDIFF, use: 

( [Date Completed] - [Date Created] ) * 1.
 
Then check for >= 0 && <= 7
 
Those without a Date Completed will be negative

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

@Greg_Deckler 

Thanks for the reply. you helped me to a solution.  this was what ended up working for me. For some reason, i was getting an error for ' >= 0 && <= 7'

 

 

 

# of Days to Clear 2 = var _diff = ([Date Completed]-[Date Created]*1)
return

Switch(True() ,

_diff <=-1, "Remaining Open",
_diff <=7, "Cleared in 7 days or less",
_diff <=30 , "  Cleared in 8 to 30 days",
_diff <=60 , " Cleared in 31 to 60 days",
_diff <=90, " Cleared in 61 to 90 days",
_diff <=120, " Cleared in 91 to 120 days",
_diff >120, "Cleared in 120 days or more"
--_diff =blank(), "remaining open"
)

View solution in original post

4 REPLIES 4
Delguy87
Frequent Visitor

thanks, that worked as well! 

Greg_Deckler
Super User
Super User

@Delguy87 Instead of DATEDIFF, use: 

( [Date Completed] - [Date Created] ) * 1.
 
Then check for >= 0 && <= 7
 
Those without a Date Completed will be negative

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

Thanks for the reply. you helped me to a solution.  this was what ended up working for me. For some reason, i was getting an error for ' >= 0 && <= 7'

 

 

 

# of Days to Clear 2 = var _diff = ([Date Completed]-[Date Created]*1)
return

Switch(True() ,

_diff <=-1, "Remaining Open",
_diff <=7, "Cleared in 7 days or less",
_diff <=30 , "  Cleared in 8 to 30 days",
_diff <=60 , " Cleared in 31 to 60 days",
_diff <=90, " Cleared in 61 to 90 days",
_diff <=120, " Cleared in 91 to 120 days",
_diff >120, "Cleared in 120 days or more"
--_diff =blank(), "remaining open"
)

@Delguy87 That was short-hand. The actual code would have been _diff >= 0 && _diff <= 7


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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.