Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Subtracting row from previous row to get current row

I need a DAX to calculate the following.... 

 

 




The DAX for Change

 

 = Orginal QTD (using total by quarter measure) - Current QTD(using total by quarter measure) 



I have a Values column which is the Monthly goal total.  I need to work my way backwards from the example of 2603 and minus the quarterly change EX: 0 to get the row above it(2603).  For the next row, minus $25 from $2603 etc...  The tricky part is the 2603 is the total of a different column. 

So if I have 
Quarter     Change      Calculation 
1 2021        0               2603
2 2021        0               2603
3 2021       25              2603
4 2021       63              2578 
1 2022      33               2515
2 2022      56               2482 
3 2022      0                 2426
Blank**** 137 
 
*****(I have data with no dates) 
I hope that makes sense! 
  • Try  this ...

     

    Use Power query to derive a date from the quarter. Either the first date or the last dfate of th quater will suffice.

     

    Then relate date to a standard Calendar table which has a quater offset column

     

    Then create measure using offsets ....

     

    This quarter value = CALCULATE( SUM(table[value], DimCalandar[quarteroffset= 0)

     

    Previous quarter value = CALCULATE( SUM(table[value], DimCalandar[quarteroffset= -1)

     

    Difference = [This quarter value] - [Previous quarter value] =

     

     

     

    Do all these free training modules to learn about Calandars and offsets

    https://www.youtube.com/playlist?list=PL7GQQXV5Z8eczWqKFMDVoHMjTcpH3tgZm

     

    Thanks for reaching out for help.

    I put in a lot of effort to help you, now please quickly help me by giving kudos.

    Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

    If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

    One question per ticket please. If you need to extend your request then please raise a new ticket.

    You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

     

1 Reply

  • Try  this ...

     

    Use Power query to derive a date from the quarter. Either the first date or the last dfate of th quater will suffice.

     

    Then relate date to a standard Calendar table which has a quater offset column

     

    Then create measure using offsets ....

     

    This quarter value = CALCULATE( SUM(table[value], DimCalandar[quarteroffset= 0)

     

    Previous quarter value = CALCULATE( SUM(table[value], DimCalandar[quarteroffset= -1)

     

    Difference = [This quarter value] - [Previous quarter value] =

     

     

     

    Do all these free training modules to learn about Calandars and offsets

    https://www.youtube.com/playlist?list=PL7GQQXV5Z8eczWqKFMDVoHMjTcpH3tgZm

     

    Thanks for reaching out for help.

    I put in a lot of effort to help you, now please quickly help me by giving kudos.

    Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

    If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

    One question per ticket please. If you need to extend your request then please raise a new ticket.

    You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !