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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
SIGSME
New Member

CALCULATE TIME INTERVAL WITH CONDITIONS

I am trying to get the result out from the time interval table. On Certain Conditions. 

SIGSME_0-1631449361088.png

Here is my data I have Condition Colum with different variables "START" "END" RESUME. I want to calculate time interval in minutes based on conditions from START to END where my SLine = Sline and Line = Line and Docno = DocNo 

Total Time = CONDITION(START-END)

BREAK TIME = CONDITON SUM(BRK+END)

Process Time = Total Time - Break Time

 

My result will look similar to the one below. 

SIGSME_1-1631449805170.png

 

 

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

Hi, 

According to your description, I can roughly understand your requirement, I created some test data to achieve your requirements, you can try my steps:

This is the test data I created based on your data model:

vrobertqmsft_0-1631697922380.png

 

I created three measures like this:

Total Time =

var _start=CALCULATE(MAX('Table'[Time]),FILTER(ALL('Table'),[DocNo]=MAX('Table'[DocNo])&&[Line]=MAX('Table'[Line])&&[SLine]=MAX('Table'[SLine])&&[Status]="Start"))

var _end=CALCULATE(MAX('Table'[Time]),FILTER(ALL('Table'),[DocNo]=MAX('Table'[DocNo])&&[Line]=MAX('Table'[Line])&&[SLine]=MAX('Table'[SLine])&&[Status]="End"))

return

DATEDIFF(_start,_end,MINUTE)
Breaktime = SUM('Table'[Break Time])
Process Time = [Total Time]-[Breaktime]

Then I create a table chart and place it like this:

vrobertqmsft_1-1631697922385.png

 

And you can get what you want.

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, I created some test data to achieve your requirements, you can try my steps:

This is the test data I created based on your data model:

vrobertqmsft_0-1631697922380.png

 

I created three measures like this:

Total Time =

var _start=CALCULATE(MAX('Table'[Time]),FILTER(ALL('Table'),[DocNo]=MAX('Table'[DocNo])&&[Line]=MAX('Table'[Line])&&[SLine]=MAX('Table'[SLine])&&[Status]="Start"))

var _end=CALCULATE(MAX('Table'[Time]),FILTER(ALL('Table'),[DocNo]=MAX('Table'[DocNo])&&[Line]=MAX('Table'[Line])&&[SLine]=MAX('Table'[SLine])&&[Status]="End"))

return

DATEDIFF(_start,_end,MINUTE)
Breaktime = SUM('Table'[Break Time])
Process Time = [Total Time]-[Breaktime]

Then I create a table chart and place it like this:

vrobertqmsft_1-1631697922385.png

 

And you can get what you want.

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

GilbertQ
Super User
Super User

Hi @SIGSME 

 

What you would need to do is to convert your times to seconds.

 

Then create the measures based on the seconds and finally display the final outcome using a formatting option.

 

Here is my blog post with more details: Convert from Seconds to Minutes with a DAX Measure - Reporting/Analytics Made easy with FourMoo and ...





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

Proud to be a Super User!







Power BI Blog

HI @GI

I Understand that this needs to be converted into seconds but how will do the rest out of it as i am totally new to PBI

Here is my data I have Condition Colum with different variables "START" "END" RESUME. I want to calculate time interval in minutes based on conditions from START to END where my SLine = Sline and Line = Line and Docno = DocNo 

Total Time = CONDITION(START-END)

BREAK TIME = CONDITON SUM(BRK+END)

Process Time = Total Time - Break Time

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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