Forum Discussion
$Expr0 := CallbackDataID
Performance tuning is highly situational. Eliminating callbackdataid isn't always a good idea. It depends. Your second version requires iterating through 'AccountTransaction' twice instead of just once.
I'm not sure this will work but it may give you an idea of another path to try:
CALCULATE (
CALCULATE ( [Debit] - [Credit], Accounts[Account Group] = 1 ) +
CALCULATE ( [Credit] - [Debit], Accounts[Account Group] = 2 ),
FILTER ( ALL ( Dates[Date] ), Dates[Date] <= MAX ( 'Dates'[Date] ) )
)
Thank you very much for the support. The following are the results using three difference versions
CALCULATE(
SUMX(FILTER('AccountTransactions',(RELATED(Accounts[Account Group])=1 || RELATED(Accounts[Account Group])=2)),
if(RELATED(Accounts[Account Group])=1,[Debit]-[Credit],[Credit]-[Debit])),
FILTER (
ALL ( Dates[Date] ),
Dates[Date]<= MAX ( 'Dates'[Date])
)
)
CALCULATE(
CALCULATE(
SUMX(FILTER('AccountTransactions',RELATED(Accounts[Account Group])=1),
[Debit]-[Credit])
)
+
CALCULATE(
SUMX(FILTER('AccountTransactions',RELATED(Accounts[Account Group])=2),
[Credit]-[Debit])),
FILTER (
ALL ( Dates[Date] ),
Dates[Date]<= MAX ( 'Dates'[Date])
)
)
Made changes to the model to include account group in the same table
CALCULATE(
CALCULATE(
SUMX(FILTER('AccountTransactions',[Account Group]=1),
[Debit]-[Credit])
)
+
CALCULATE(
SUMX(FILTER('AccountTransactions',[Account Group]=2),
[Credit]-[Debit])),
FILTER (
ALL ( Dates[Date] ),
Dates[Date]<= MAX ( 'Dates'[Date])
)
)