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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MAZHAR
Frequent Visitor

CALCLATE TIME BETWEN INTERVALS

Screenshot 2023-07-06 145041.png

I have a large Excel sheet like this where Document Numbers will be listed along with all other information as in the picture. I want to calculate the following. 

  1. Total Time (Minutes) = (START-END)
  2. Break Time (Minutes) = (RESUME- PP)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MAZHAR ,

 

I suggest you to create  virtual table in your calculation and then use SUMX to achieve your goal.

Total Time =
VAR _SUMMARIZE =
    SUMMARIZE (
        'MCH_WorkStatusD',
        MCH_WorkStatusD[Line],
        MCH_WorkStatusD[SCP_Line],
        "Diff",
            VAR _STATR =
                CALCULATE (
                    MAX ( MCH_WorkStatusD[Time] ),
                    MCH_WorkStatusD[CONDITION] = "START"
                )
            VAR _END =
                CALCULATE ( MAX ( MCH_WorkStatusD[Time] ), MCH_WorkStatusD[CONDITION] = "END" )
            RETURN
                DATEDIFF ( _STATR, _END, MINUTE )
    )
RETURN
    SUMX ( _SUMMARIZE, [Diff] )

Result is as below.

vrzhoumsft_0-1688974373983.png

 

Best Regards,
Rico Zhou

 

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

4 REPLIES 4
MAZHAR
Frequent Visitor

Screenshot 2023-07-07 103444.png

I tried the following solution which is not giving me the exact total time on one Document Number, it gives me accurate time on the last level which is SCP_LINE but on combining all it fails.

I created three measures to calculate Total Time

START TIME = CALCULATE(MAX(MCH_WorkStatusD[Time]), MCH_WorkStatusD[CONDITION] = "START")
END TIME = CALCULATE(MAX(MCH_WorkStatusD[Time]), MCH_WorkStatusD[CONDITION] = "END")
STAGE = DATEDIFF([START TIME],[END TIME],MINUTE)

 

Anonymous
Not applicable

Hi @MAZHAR ,

 

I suggest you to create  virtual table in your calculation and then use SUMX to achieve your goal.

Total Time =
VAR _SUMMARIZE =
    SUMMARIZE (
        'MCH_WorkStatusD',
        MCH_WorkStatusD[Line],
        MCH_WorkStatusD[SCP_Line],
        "Diff",
            VAR _STATR =
                CALCULATE (
                    MAX ( MCH_WorkStatusD[Time] ),
                    MCH_WorkStatusD[CONDITION] = "START"
                )
            VAR _END =
                CALCULATE ( MAX ( MCH_WorkStatusD[Time] ), MCH_WorkStatusD[CONDITION] = "END" )
            RETURN
                DATEDIFF ( _STATR, _END, MINUTE )
    )
RETURN
    SUMX ( _SUMMARIZE, [Diff] )

Result is as below.

vrzhoumsft_0-1688974373983.png

 

Best Regards,
Rico Zhou

 

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

tamerj1
Super User
Super User

Hi @MAZHAR 
How many poses there could be? Or just once?

@tamerj1 Thanks for your reply it is 5 the moment I just share an example of one.

  1. PP
  2. BRK
  3. MSC
  4. 1x2x

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.