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

Difference between two rows with previous day, same Work Item Id

Completed Daily = for a given row, it is the difference between the Completed Work column and the previous value (previous day, same Work Item Id)

 

http://prntscr.com/ktxpn4

 

 

Screenshot_7.png

 

Example: 

 

For Work ID: 85643

 

I need result:

First Row: 0

Scond Row: 2.5

Third Row: 4.5-2.5 = 2

Forth Row 9.00-4.5= 4.50

 

Need to subtracted above row value with group by of column (Work ID and Date) 

 

Reult look like this:

 

Screenshot_10.png

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

You can try to use below calculate column formula to achieve your requirement:

Completed Daily =
VAR previous =
    CALCULATE (
        MAX ( Test[Changed Date] ),
        FILTER (
            ALL ( Test ),
            [Work Item Id] = EARLIER ( [Work Item Id] )
                && [Changed Date] < EARLIER ( Test[Changed Date] )
        )
    )
RETURN
    [Work]
        - LOOKUPVALUE (
            Test[Work],
            Test[Work Item Id], [Work Item Id],
            Test[Changed Date], previous
        )

14.PNG

 

Regards.

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Try this calculated column

 

Completed Daily =
[work]
    - MINX (
        TOPN (
            1,
            FILTER (
                table1,
                [Work Item Id] = EARLIER ( [Work item Id] )
                    && [Changed date] > EARLIER ( [Changed date] )
            ),
            [Changed Date], ASC
        ),
        [Work]
    )

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

@Zubair_Muhammad

 

Thanks This logic helpful. 

 

But Stil have one problem. It show result in Wrong column. 

it show result in wrog rows.

 

First Row show have result 0 and second row result is -2.5 like this 
0

2

2.5

4.5

0

 

 

Screenshot_11.png

Hi @Anonymous,

 

You can try to use below calculate column formula to achieve your requirement:

Completed Daily =
VAR previous =
    CALCULATE (
        MAX ( Test[Changed Date] ),
        FILTER (
            ALL ( Test ),
            [Work Item Id] = EARLIER ( [Work Item Id] )
                && [Changed Date] < EARLIER ( Test[Changed Date] )
        )
    )
RETURN
    [Work]
        - LOOKUPVALUE (
            Test[Work],
            Test[Work Item Id], [Work Item Id],
            Test[Changed Date], previous
        )

14.PNG

 

Regards.

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hi 

May I know the formula in Power BI to calculate the [Gap Days] between two dates in a row for specific item?

Currently I want to calculate difference between two rows based on specific item. This is my data:

 
ItemDateGap Days
A1-Jan-20 
A7-Jan-206
A10-Jan-203
B2-Jan-20 
B5-Jan-203
C8-Jan-20 
C16-Jan-208
C25-Jan-209
D15-Jan-20 
D31-Jan-2016

 

The gap days is the dates in the row minus the date in the previous row for the same item. 

Really appreciate your help.

 

Thanks

Regards,

Caroline

Anonymous
Not applicable

Thank you so much for help

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.