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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Community Champion
Community Champion

@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!:
DAX For Humans

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
Community Champion
Community Champion

@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!:
DAX For Humans

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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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