Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
hari127
Frequent Visitor

$Expr0 := CallbackDataID

The following code is rewritten to eliminate the callbackdataid but it increased SE Queries and decreased SE Cache and overall performance degraded. Is callbackdataid good or bad,  Is this the correct method to eliminate callbackdataid? Why performance is degraded?

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])
)
)

---------------new code to eliminate callbackdataid

CALCULATE(
SUMX(FILTER('AccountTransactions',RELATED(Accounts[Account Group])=1),
[Debit]-[Credit]),

FILTER (
ALL ( Dates[Date] ),
Dates[Date]<= MAX ( 'Dates'[Date])
)
)
+
CALCULATE(
SUMX(FILTER('AccountTransactions',RELATED(Accounts[Account Group])=2),
[Credit]-[Debit]),

FILTER (
ALL ( Dates[Date] ),
Dates[Date]<= MAX ( 'Dates'[Date])
)
)

6 REPLIES 6
daxer-almighty
Solution Sage
Solution Sage

If you want to have fast DAX, then never ever call a measure when iterating a fact table row by row.

 

Did you find any measure in my code?

I use THESE conventions to interpret DAX code when I read it. If you don't follow this golden standard, then you should not be surprised that people do not understand your code.

Thanks

AlexisOlson
Super User
Super User

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])
)
)

 

hari127_0-1622871566579.png

 

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])
)
)

hari127_1-1622871881683.png

 

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])
)
)

 

hari127_2-1622872598710.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.