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
mohamedh
Frequent Visitor

Calculation using previous day value

Hi Is there a way to do a calucation whereby i can add my previous day value to my current day calculation?

 

eg. previous day closing stock + opening stock current day =

 

Thanks

2 ACCEPTED SOLUTIONS
v-huizhn-msft
Employee
Employee

Hi @mohamedh,

Of course, you should lookup the previous day first, then calcualte it using calculated column.

I create sample data table.

 

1.PNG

 

Create a column ranked by date, then lookup the previous day value based on the rank colculated column.

 

Rank = RANKX(Test,Test[Date],,ASC)

previous day closing value = LOOKUPVALUE(Test[closing stock],Test[Rank],Test[Rank]-1)


Finally add the current day value and previous day value together. Please see the formula and screenshot below.

 

previous-day-closing+opening-stock-current-day = Test[closing stock]+Test[previous day closing value]

2.PNG


If you have other issues, don't hesitate to let me know.

 

Best Regards,
Angelia

View solution in original post

CheenuSing
Community Champion
Community Champion

Hi @mohamedh

 

The link

 

http://blog.gbrueckl.at/2015/04/recursive-calculations-powerpivot-dax/

 

may be helpful. Check it out. If it solves your issue please give KUDOS.

 

Cheers

 

CheenuSing

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
CheenuSing
Community Champion
Community Champion

Hi @mohamedh

 

The link

 

http://blog.gbrueckl.at/2015/04/recursive-calculations-powerpivot-dax/

 

may be helpful. Check it out. If it solves your issue please give KUDOS.

 

Cheers

 

CheenuSing

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
v-huizhn-msft
Employee
Employee

Hi @mohamedh,

Of course, you should lookup the previous day first, then calcualte it using calculated column.

I create sample data table.

 

1.PNG

 

Create a column ranked by date, then lookup the previous day value based on the rank colculated column.

 

Rank = RANKX(Test,Test[Date],,ASC)

previous day closing value = LOOKUPVALUE(Test[closing stock],Test[Rank],Test[Rank]-1)


Finally add the current day value and previous day value together. Please see the formula and screenshot below.

 

previous-day-closing+opening-stock-current-day = Test[closing stock]+Test[previous day closing value]

2.PNG


If you have other issues, don't hesitate to let me know.

 

Best Regards,
Angelia

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.