PowerBI DAX - Running total

jorgemaiden

New Member
Joined
Mar 18, 2012
Messages
2
Hello,

I'm relatively new to Power BI. I'm stuck with a formula for some time now so any help would be appreciated.

I need the running total (YTM) for the ammount balance, depending on the year and month selected on the slicers.

The model (simplified) is as following



jorge_oliveira_0-1644343943516.png




I'm using two measures:

Excel Formula:
[Accumulated Balance] = SUM(PROFIT_CENTER[AMT_BALANCE])+0

Excel Formula:
AMT_BALANCE_YTD =
VAR YEAR = SELECTEDVALUE(PROFIT_CENTER[YEAR])
VAR MONTH = SELECTEDVALUE(PROFIT_CENTER[MONTH])
return
CALCULATE([Accumulated Balance];
FILTER(ALLEXCEPT(PROFIT_CENTER;DIM_STRUCTURE);PROFIT_CENTER[YEAR] = YEAR && PROFIT_CENTER[MONTH] <= MONTH))

The error I'm getting occurs when I select a month that doesn't have any value to a specific ID_COST_CENTER / ID_ACCOUNT, as in the example below - in green what I expect to see in a card depending on the year/month selected and in red what I'm getting with the formula I'm using.
As you can see, when I select May, I'm getting a zero instead of 4306. In May the pair ID_COST_CENTER a / ID_ACCOUNT 123 doesn't exist, but I need to show the total for the year.

jorge_oliveira_1-1644344417016.png


jorge_oliveira_2-1644344427253.png


How can I change the formula to obtain the desired results?

Thanks for your help.
Jorge
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,676
Messages
6,173,773
Members
452,534
Latest member
autodiscreet

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