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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
samdep
Advocate II
Advocate II

Calculate Difference Between Rows (Row Data is a Measure, Not a Calc Column)

Hi Everyone,

 

I am looking to calculate the marginal product count to understand where we're seeing diminishing returns.

 

I have two columns of data - Days (which is a calculated DateDiff column I built in the table) and Product Count (which is a measure I created -- counting incidences of the sale of Product X).

 

I've seen a lot of solutions for calculating a running difference between current row and previous row where the row data is coming from calculated column in the table, but not where the row level data is a measure -- any help would be greatly appreciated!

 

 

Product Sales Data --

Day (Calc Column in Table)    Product Count (Measure)   Marginal Product Count

0                                             10 

1                                             12                                                  2

2                                             20                                                  8

 

And so on... 

 

Thank you! 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @samdep 

Please check the below picture and the link down below (sample pbix file) whether it is what you are looking for.

The measure is in the sample pbix file.

 

Picture2.png

 

Diff qty count =
VAR currentnumber =
MAX ( 'Table'[Day Calc Column] )
VAR onerowbefore =
CALCULATE (
MAX ( 'Table'[Day Calc Column] ),
FILTER ( ALL ( 'Table' ), 'Table'[Day Calc Column] < currentnumber )
)
VAR onerowbeforeqty =
CALCULATE ( [total qty], 'Table'[Day Calc Column] = onerowbefore )
RETURN
IF ( NOT ISBLANK ( onerowbeforeqty ), [total qty] - onerowbeforeqty, BLANK () )

 

 

https://www.dropbox.com/s/afahpn09tch8lii/samdep.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
samdep
Advocate II
Advocate II

Hi Jihwan,

 

This worked perfectly! Thank you so much for your help!! 

Jihwan_Kim
Super User
Super User

Hi, @samdep 

Please check the below picture and the link down below (sample pbix file) whether it is what you are looking for.

The measure is in the sample pbix file.

 

Picture2.png

 

Diff qty count =
VAR currentnumber =
MAX ( 'Table'[Day Calc Column] )
VAR onerowbefore =
CALCULATE (
MAX ( 'Table'[Day Calc Column] ),
FILTER ( ALL ( 'Table' ), 'Table'[Day Calc Column] < currentnumber )
)
VAR onerowbeforeqty =
CALCULATE ( [total qty], 'Table'[Day Calc Column] = onerowbefore )
RETURN
IF ( NOT ISBLANK ( onerowbeforeqty ), [total qty] - onerowbeforeqty, BLANK () )

 

 

https://www.dropbox.com/s/afahpn09tch8lii/samdep.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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