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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Replicate excel formula - recursive substraction

Hi there. I am trying to replicate excel formula in power BI DAX. I have date column(A) with date, progress column(B) with integer, left column(C) with integer. This meant to be project progress monitoring tool. So the team is starting with 100k instances to process and on each day they do certain progress, so in the cell C2 = 100000-B2,but starting from C3 = C2 - B3, C4 = C3 - B4 and so on...

 

Help will be appreciated.

Thanks,

Michal

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

You can do this by calculating a running total or cumulative sum. Then just do 100000- running total.

So for your example:
Remaining instances = 100000- SUMX(FILTER(ALL(Table), Table[Date] >= EARLIER(Table[Date]) ), Table[left])

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

3 REPLIES 3
AllisonKennedy
Super User
Super User

You can do this by calculating a running total or cumulative sum. Then just do 100000- running total.

So for your example:
Remaining instances = 100000- SUMX(FILTER(ALL(Table), Table[Date] >= EARLIER(Table[Date]) ), Table[left])

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Thanks a lot! That was exactly what i was needing. I only changed 

aggregate_instances_by_date[last_updated] >= EARLIER(aggregate_instances_by_date[last_updated] to:
aggregate_instances_by_date[last_updated] <= EARLIER(aggregate_instances_by_date[last_updated]
 
so it is the right chronological way 
amitchandak
Super User
Super User

@Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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