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
JWE
Helper I
Helper I

Compare Rows and sum

Hi folks

 

I need help for this scenario.

For 4 inbound deliveries (from the same vendor) I have 4 rows with date and time.

When I calculate the time in minutes (Minuten je Beleg) and sum the column I get the complete sum (660.46 min) of each inbound.

 

Problem: I only want the (start-end) sum like marked in red.

ExamplePBI.jpg

Means: The duration of all inbounds for one vendor at one day e.g. ~262 minutes.

 

And to make it more challenging - only when there is no gap between the times, means when there is an overlap of all times.

 

Any idea - thanks Jorg

 

 

3 REPLIES 3
JWE
Helper I
Helper I

Another note:

How can I recognize and conisder the gap in the times from different documents.

 

Another example like before:

When I select the date (06.01.2016) I get 4 douments.

In this case I have one (LagerNr B213121) without overlapping time with the other 3.

This ends before the new starttime of the next document (higlighted in yellow).

 

PBI-4.jpg

 

So the result (sum of time) is not what I need.

In these special cases I want the sum of the two different results (8,52 + 178,17=186,69).

 

How to realised that?

 

Thanks in advanced Jorg

JWE
Helper I
Helper I

PBI-1.jpg

Hi Yuliana

thanks for help.

When I use your DAX (syntax see below) I get the result in picture 1.

Only when I select the items in the slicer (picture 2) I get the correct result.

It should also work without the selection - is it possible?

 

PBI-2.jpg


Yuliana =
DATEDIFF (
    CALCULATE (
        MIN ( 'Lagerbeleg'[Start DatumUhrzeit] );
        ALLEXCEPT ( 'Kreditor'; 'Kreditor'[KreditorNr] )
    );
    CALCULATE (
        MAX ( 'Lagerbeleg'[Ende DatumUhrzeit] );
        ALLEXCEPT ( 'Kreditor'; 'Kreditor'[KreditorNr] )
    );
    SECOND)
    / 60

v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @JWE,

 

Please refer to below measure;

Sum Between Start and End =
DATEDIFF (
    CALCULATE (
        MIN ( 'Compare Rows and sum'[Start] ),
        ALLEXCEPT ( 'Compare Rows and sum', 'Compare Rows and sum'[KreditorNr] )
    ),
    CALCULATE (
        MAX ( 'Compare Rows and sum'[End] ),
        ALLEXCEPT ( 'Compare Rows and sum', 'Compare Rows and sum'[KreditorNr] )
    ),
    SECOND
)
    / 60

Result:
1.PNG

 

If I have something misunderstood, please correct me and describe your requirment more clearly.

 

Thanks,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.