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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.