Converting excel formula to DAX

ncguy55

New Member
Joined
Jan 31, 2024
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi - I am working on converting an excel document into Power BI. I am struggling to figure out how to convert this formula to DAX:

=MIN(SUMIF(Paydowns[Facility Number],[@[Facility Number]],Paydowns[Transaction Value])-SUMIF(OFFSET(Schedule[[#Headers],[Facility Number]],0,0,ROW([@[Facility Number]])-ROW(Schedule[[#Headers],[Facility Number]])),[@[Facility Number]],OFFSET(Schedule[[#Headers],[Payment Amount]],0,0,ROW([@[Facility Number]])-ROW(Schedule[[#Headers],[Facility Number]]))),[@[Advance Amount]])

Thanks in advance for the help!
 
It is pretty much always a mistake to try and directly convert an Excel formula to DAX since the underlying structures and output visuals are quite different.

What are you actually trying to calculate?
 
Upvote 0
Understand, the offset portion of this formula is what I can't figure out. It Sums the payment amounts above the current cell if the facility number matches the current row.

Facility Number Payment AmountOffset
1 200,204 -
1 17,796 200,204
1 67,847 218,000
2 68,184 -
2 131,122 68,184
2 91,786 199,306
2 65,561 291,092
Offset Portion:
SUMIF(OFFSET(Schedule[[#Headers],[Facility Number]],0,0,ROW([@[Facility Number]])-ROW(Schedule[[#Headers],[Facility Number]])),[@[Facility Number]],OFFSET(Schedule[[#Headers],[Payment Amount]],0,0,ROW([@[Facility Number]])-ROW(Schedule[[#Headers],[Facility Number]]))
 
Upvote 0
That's basically a running total, which you would typically do as a measure not a calculated column, but that could be tricky either way given that you don't appear to have anything that would indicate an order (row numbers aren't really a thing). If you use PQ to load the data into the data model, you could add an index column, and then you can create a measure that sums all values for the current facility where the index is less than the current index value.
 
Upvote 0
Solution
Yes, I could add the index number in PQ. I will try to see if I can figure the measure out. Thanks for your help!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top