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

Subtracting from a previous row calculation

Hi, 

I am trying to calcute a projection for next year. How this is calculated is the total Products is subrtracted from current improvemnts and the new value calulated will be the new total products. However currently my table is always subtracting from 2603 rather than updating with the new value. 

HELP_PLS_0-1664190027481.png

 

 

 

 

Goal: 

 

Total products = 2603 

Current Improvements = 25 

2603 - 25 = 2578 

 

New Value total Prouct = 2578 

 

2578 - Next value for current improvements

 

and so on.. 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, if you only want to get value in the previous row, simply add an index column in Power Query. Or if you want to get value of the previous quarter, firstly create a calculated column.

Rank =
RANKX ( 'Table', 'Table'[Year] & 'Table'[Quarter],, ASC )

 It will return a rank according to the year and quarter.

vkalyjmsft_0-1664247003786.png

Then create another calculated column.

Column =
MAXX (
    FILTER ( 'Table', 'Table'[Rank] = EARLIER ( 'Table'[Rank] ) - 1 ),
    'Table'[Current Improvements Graph]
) - 'Table'[Current Improvement1]

Get the result.

vkalyjmsft_1-1664247175351.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

4 REPLIES 4
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

Is your problem solved? If so, would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirment will find the solution quickly and benefit here, thank you!

Best Regards,
Community Support Team _ kalyj

v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, if you only want to get value in the previous row, simply add an index column in Power Query. Or if you want to get value of the previous quarter, firstly create a calculated column.

Rank =
RANKX ( 'Table', 'Table'[Year] & 'Table'[Quarter],, ASC )

 It will return a rank according to the year and quarter.

vkalyjmsft_0-1664247003786.png

Then create another calculated column.

Column =
MAXX (
    FILTER ( 'Table', 'Table'[Rank] = EARLIER ( 'Table'[Rank] ) - 1 ),
    'Table'[Current Improvements Graph]
) - 'Table'[Current Improvement1]

Get the result.

vkalyjmsft_1-1664247175351.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

Anonymous
Not applicable

Hi, 

Thank you very much for your help. However, I am gettng an error when creating the rank. I take the year and the quarter from the created date of my data. 

 

HELP_PLS_0-1664265832348.png

 

Hi @Anonymous ,

From the error message, do you create a measure by the code? Can you create a calculated column by the code.

Additionally, this is a visual, is it the same format in the data table.

vkalyjmsft_0-1664346296458.png

Best Regards,
Community Support Team _ kalyj

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.