Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hello,
I would like to ask you about specyfic case. My examle is below. I need to have some YTD calculation across multiple years. It means that I want to see one column "Opening balance" it is not standard functionality OPENINGBALANCE in DAX, it need to be sth more. Opening balance for current month is closing balance for previous month, and closing balance is YTD calculation but I must have this value from the beggining of the world till now, so it is not only current year.
So I prepare closing balance in DAX like
// You should adjust the names of
// the tables and columns to fit
// your model. These measures work
// correctly for any selection of
// periods, not only months.
[Closing Balance] =
var LastVisibleDate = MAX( 'Calendar'[Date] )
var Result =
CALCULATE(
SUM( T[Amount] ),
'Calendar'[Date] <= LastVisibleDate,
// This last line is not needed
// if 'Calendar' is a date table
// that's been marked in the model
// as a proper date table.
ALL( 'Calendar' )
)
return
Result
// Opening Balance
[Opening Balance] =
var FirstVisibleDate = MIN( 'Calendar'[Date] )
var DayBeforeFirstVisibleDate =
FirstVisibleDate - 1
var Result =
CALCULATE(
[Closing Balance],
'Calendar'[Date] = DayBeforeFirstVisibleDate,
// Same remark as above applies...
ALL( 'Calendar' )
)
return
Result
Unfortunatelly, I put this formulas in mine .pbix and not working correctly