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
Anonymous
Not applicable

Date/TIme variance based on day only (ignoring time)

I have got two date/time fields in the table that I am using in a nested if statement that calculates the variance between them. I want power bi to ignore the hours completely and calculate the variance based on days only

Example:

What I get : (01/01/2020 00:00:00) -( 01/01/2020 17:00:00) =  1

What I would like to see  (01/01/2020 00:00:00) -( 01/01/2020 17:00:00) =   0 ( because the day is the same) 

Formula extract:

VAR = IF(ISBLANK(tasks[TaskFinishDate]), 9999,
IF(tasks[DEP TYPE1]="GIVE",(tasks[ Forecast 9th Mar]- tasks[TaskFinishDate]),
 8888))
 
Thank you 
 
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Use INT([datetime])

 

This will drop the decimal portion of your date time column.


@ 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

4 REPLIES 4
Anonymous
Not applicable

The best way is to store date and time separately. Then you won't have such problems.

Best
D
Greg_Deckler
Super User
Super User

Use INT([datetime])

 

This will drop the decimal portion of your date time column.


@ 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...
Anonymous
Not applicable

@Greg_Deckler  Thank you very much, one last question is there a way to apply INT per formula rather than per each date column ( as my formula has quite a few lines) ?  

so that instead of INT(date1)-INT(date2)

something like INT([date1]-[date2]) - this didnt work but wondering if there is a way to do this ?

 

Thank you

 

Might be able to use TRUNC

@ 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors