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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Razvan66
Frequent Visitor

Delta between values in the same column

Hello together,

 

Have a question about a calculation.

 

Razvan66_0-1726561226519.png

So, i have this matrix, what im intrested to do i a delta between each release numbers to calculate the difference. Now the problem is that quantities come from the the column and there is also the deliv date to take into consideration, something like IF release no = earlier release no AND deliv. date (release 290) = deliv.date (release 288) ==> delta

1 ACCEPTED SOLUTION

Hi @Razvan66 ,hello danextian,thank you for your prompt reply!

 

Please check the following measure:

 

Delta Between Versions = 
VAR CurrentRelease = SELECTEDVALUE('Table'[Release No])
VAR CurrentDate = SELECTEDVALUE('Table'[Deliv. Date])
VAR PreviousRelease = CALCULATE(MAX('Table'[Release No]), 'Table'[Release No] < CurrentRelease, 'Table'[Deliv. Date] = CurrentDate)
VAR CurrentQuantity = CALCULATE(SUM('Table'[Quantity]), 'Table'[Release No] = CurrentRelease, 'Table'[Deliv. Date] = CurrentDate)
VAR PreviousQuantity = CALCULATE(SUM('Table'[Quantity]), 'Table'[Release No] = PreviousRelease, 'Table'[Deliv. Date] = CurrentDate)
RETURN
IF(NOT(ISBLANK(PreviousRelease)), CurrentQuantity - PreviousQuantity, BLANK())

 Result:

vyajiewanmsft_0-1726646806900.png

Best regards,

Joyce

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

View solution in original post

5 REPLIES 5
Razvan66
Frequent Visitor

Hi @danextian , here is a small sample of the data

 

Release no.290 288
Deliv. Date12.septDelta05.sept
20.sept0-1260012600
02.oct21540215400
04.oct000
09.oct23400546017940

Hi @Razvan66 ,hello danextian,thank you for your prompt reply!

 

Please check the following measure:

 

Delta Between Versions = 
VAR CurrentRelease = SELECTEDVALUE('Table'[Release No])
VAR CurrentDate = SELECTEDVALUE('Table'[Deliv. Date])
VAR PreviousRelease = CALCULATE(MAX('Table'[Release No]), 'Table'[Release No] < CurrentRelease, 'Table'[Deliv. Date] = CurrentDate)
VAR CurrentQuantity = CALCULATE(SUM('Table'[Quantity]), 'Table'[Release No] = CurrentRelease, 'Table'[Deliv. Date] = CurrentDate)
VAR PreviousQuantity = CALCULATE(SUM('Table'[Quantity]), 'Table'[Release No] = PreviousRelease, 'Table'[Deliv. Date] = CurrentDate)
RETURN
IF(NOT(ISBLANK(PreviousRelease)), CurrentQuantity - PreviousQuantity, BLANK())

 Result:

vyajiewanmsft_0-1726646806900.png

Best regards,

Joyce

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

Hello,

 

Thank you very much for the solution, it works.

 

But now another issue, if i sort the column, the release no.`s are descending 290, 288 ..., its not working anymore. Did this by "sort by column"

Hi @Razvan66,

 

For sorting questions, please follow the steps below:

  • Click "Transform data" to open the data in power query:

vyajiewanmsft_0-1727229299879.png

  • Then add a conditional column with the following syntax: vyajiewanmsft_1-1727229389851.png

     

  • Next click close&apply button to return to the desktop table view, choose the ReleaseNo column, and then sort by the newly created column:

vyajiewanmsft_2-1727229605032.png

  • Lastly, we need to change the measure as shown below:
Delta Between Versions = 
VAR CurrentRelease = SELECTEDVALUE('Table'[Release No])
VAR CurrentDate = SELECTEDVALUE('Table'[Deliv. Date])
VAR PreviousRelease = CALCULATE(MAX('Table'[Release No]), 'Table'[Release No] < CurrentRelease, 'Table'[Deliv. Date] = CurrentDate,REMOVEFILTERS('Table'[SortOrder]))
VAR CurrentQuantity = CALCULATE(SUM('Table'[Quantity]), 'Table'[Release No] = CurrentRelease, 'Table'[Deliv. Date] = CurrentDate,REMOVEFILTERS('Table'[SortOrder]))
VAR PreviousQuantity = CALCULATE(SUM('Table'[Quantity]), 'Table'[Release No] = PreviousRelease, 'Table'[Deliv. Date] = CurrentDate,REMOVEFILTERS('Table'[SortOrder]))
RETURN
IF(NOT(ISBLANK(PreviousRelease)), CurrentQuantity - PreviousQuantity, BLANK())

Result for your reference:

vyajiewanmsft_3-1727232675531.png

Best regards,

Joyce

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

danextian
Super User
Super User

Hi @Razvan66 ,

 

As always, please post a workable sample data (not an image) that can be copy-pasted to Excel. A link to Excel file in the cloud will do.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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