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
SantoshKumar
Employee
Employee

Hours Calculation result after excluding the Days

Hi,

 I need to Modify Hours Column in My table. 

Currently i have two Columns 1. Days 2. Hours as shown in the pic below.CalcHours.JPG

Hours value at present is Total Hours  but my requirement is to get Hours Value if and only if Days value is zero.

ex: if day value is 1, Hours value should be zero.

if day value is zero, then only hours value should populate by excluding the days.

 

thanks

santosh

 

 

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @SantoshKumar,

 

Here we can use MOD function to work on it.

 

Hours = IF(Table1[Days]=1,0,MOD(DATEDIFF(Table1[StartTime],Table1[EndTime],HOUR),24))

2.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

4 REPLIES 4
v-frfei-msft
Community Support
Community Support

Hi @SantoshKumar,

 

Here we can use MOD function to work on it.

 

Hours = IF(Table1[Days]=1,0,MOD(DATEDIFF(Table1[StartTime],Table1[EndTime],HOUR),24))

2.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

@v-frfei-msftThanks. your query solves one of my issue.

Greg_Deckler
Super User
Super User

Try:

 

Hours = 
IF([Days]>0,0,DATEDIFF...)

So, just plug in your formula for the FALSE condition.


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

Thanks @Greg_Deckler

 

i was able to get the details in sql when i providde my query as:  DateDiff(Hour,StartTrgTime,endTrgTime)%24

when it comes to PB_query  - i have below option 

DATEDIFF(BABugs[Days],BABugs[Hours],HOUR) and it results are zero but i need remainder as my result.
 could you help me on 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.