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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SandeA
Helper III
Helper III

How to show a 1 instead of 0 on a DATEDIFF calculated column

Hello! I haven't used Power BI in over a year and now trying to remember everything (its not easy!!) I created a calculated column to show the number of days between two dates:

 

Datediff = DATEDIFF('W9 Log'[Date Received in AP],'W9 Log'[ENTERED/ REVISION DATE],DAY)
 
Many instances have the same date in both columns so the result of the DATEDIFF is 0. Is there any way to show this as a 1 instead of a 0? 
 
Thank you in advance!
Sande
1 ACCEPTED SOLUTION
VijayP
Super User
Super User

@SandeA  Same day means there is no difference hence it gives 0. 
IF(  above formula =0, above formula+1, above formula) use this to get 1 instead of 0




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


View solution in original post

4 REPLIES 4
Anonymous
Not applicable

[Datediff Adjusted] =

var Datediff = <your formula from above here>

var DatediffAdjusted = if( Datediff = 0, 1, Datediff )

return DatediffAdjusted

 

or, if you know that Datediff is always >= 0,

 

[Datediff Adjusted] =

var Datediff = <your formula from above here>

return max( Datediff, 1 )

VijayP
Super User
Super User

@SandeA  Same day means there is no difference hence it gives 0. 
IF(  above formula =0, above formula+1, above formula) use this to get 1 instead of 0




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Anonymous
Not applicable

I'm trying to modify my function to show 1 instead of 0. Here is what I have. Please help.


Days Open = DATEDIFF('Master Log'[Date Opened],'Master Log'[Date Closed],DAY)
IF DATEDIFF >= 0,Day + 1
[Datediff Adjusted] =

var Datediff = DATEDIFF('Master Log'[Date Opened],'Master Log'[Date Closed],DAY)

var DatediffAdjusted = if( Datediff = 0, 1, Datediff )

return DatediffAdjusted

Thank you @VijayP ! I knew it was an easy solution but couldn't wrap my head around it!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.