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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Incorrect DAX

Hi All,

 

Please see below data.

 
 

Capture.PNG

The column "Hire (Days)" is a calculated column created by the below DAX.

 

Hire Duration = DATEDIFF('Standing Scaffold Data'[On Hire Date],'Standing Scaffold Data'[Off Hire Date],DAY)

 

I require the calculated column to show me the hire for all items but at the moment it is not showing me the "Hire (Days)"  for items still on hire. The items that are not yet off-hire will need to show a "Hire (Days)" to the current day.

 

Is there any way I can use DAX to show me the Hire Days for all items?

 

1 ACCEPTED SOLUTION
FarhanAhmed
Community Champion
Community Champion

Hire Duration = DATEDIFF('Standing Scaffold Data'[On Hire Date],

IF(ISBLANK('Standing Scaffold Data'[Off Hire Date]),TODAY(),'Standing Scaffold Data'[Off Hire Date]),DAY)

 

Try this.







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
Pragati11
Super User
Super User

Hi @Anonymous ,

 

You can try modifying your DAX as follows:

 

Hire Duration = IF('Standing Scaffold Data'[Off Hire Date] = BLANK(), 

                               DATEDIFF('Standing Scaffold Data'[On Hire Date], TODAY(), DAY),

                               DATEDIFF('Standing Scaffold Data'[On Hire Date], 'Standing Scaffold Data'[Off Hire Date], DAY)

                            )

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Greg_Deckler
Community Champion
Community Champion

@Anonymous - Perhaps:

 

Hire Duration = 
  VAR __Diff1 = DATEDIFF('Standing Scaffold Data'[On Hire Date],'Standing Scaffold Data'[Off Hire Date],DAY)
  VAR __Diff2 = DATEDIFF('Standing Scaffold Data'[On Hire Date],TODAY(),DAY)
RETURN
  IF(ISBLANK(__Diff1),__Diff2,__Diff1)


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

Hire Duration = DATEDIFF('Standing Scaffold Data'[On Hire Date],

IF(ISBLANK('Standing Scaffold Data'[Off Hire Date]),TODAY(),'Standing Scaffold Data'[Off Hire Date]),DAY)

 

Try this.







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.