Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |