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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Matt_P
Helper I
Helper I

Grouping / Aggregation

I have the data below and was wondering how to calculate the diff column which is previous qty minus current row quantitiy while ensuring ID is the same.  Many thanks!

 

IDRecordDateAccumilated QtyDiff
506/01/20194557 
513/01/2019458629
520/01/2019460923
527/01/2019462112
510/02/201946309
517/02/2019464616
524/02/2019465812
503/03/201946580
510/03/201946580
517/03/2019469032
524/03/2019471424
530/03/2019474127

 

5 REPLIES 5
Anonymous
Not applicable

@Matt_P 

Hi,

I suggest you to create an Index column, this can make it very simple with the following formula:

diff previous.JPG

 

Result =
VAR current_ = [Index]
RETURN
    IF (
        Sheet1[Index] <> 1,
        [Accumilated Qty]
            - CALCULATE (
                MAX ( [Accumilated Qty] ),
                FILTER ( Sheet1, Sheet1[Index] = current_ - 1 ),
                FILTER ( Sheet1, Sheet1[Index] <> 0 )
            ),
        BLANK ()
    )

 

Best,
Paul

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

@Anonymous this looks like exactly what I'm looking for.  Ill try it out when i get the chance and report back/accept as soution.  Many Thanks!

 

edit.  Actually, this wouldnt work if I had an id of 4 in the same dataset as the id of 5 would it?

Anonymous
Not applicable

@Matt_P 

This formula is created by looking at the the index column, so it does not matter if your ID is 4 or 5. 
Just leave a message for any updates if needed.

 

Best, 

Greg_Deckler
Community Champion
Community Champion

See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks, looked at EARLIER but im finding it difficult to apply... hence the post. 😁

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.