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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
SMARTbyte
New Member

Recursive Measure with Parent-Child Relation

I know recursive measures have been discussed a few times in the Forum, but none of the solutions solve this issue:
First of all we are operating in Direct Query Mode:

We have a Ledger Table with Entries like:

AccountValue
11123
11156
11213
55527

 

And we have an Account table like:

AccParent
1 
111
11111
11211
555
55555

 

What I now try to achieve is to summarize the Values on their respective Account Levels.

 

My Idea was to create a Measure in the Account Table like:

Account.Amount = SUM(Ledger.Value)

 

I have this, and it works fine, but what I would now need to cover the higher accounts in the hierarchy is:

Account.Amount = SUM(Ledger.Value) + CALCULATE(SUM(ChildAccount.Amount), ChildAccount.Parent = ThisAccount.Acc)

 

Or in Words: When I am on a Child Record, summarize the Value in the Ledger,

If I am on a parent Record, summarize the Value in the Ledger, and add the (summarized Value) from the Child Accounts.

And I need to be able to do this recursive Measure through 3-9 Account Measure Levels?

 

If DAX would be a programming Language that would not be a problem, but esp. with Direct Queries in Mind, I know it is not that easy.

 

I don't know if that helps, but on option that came to my mind was, to have kind-of a lookup funtion for all Sub-Level Accounts, and then create a generic filter on the Ledger like CALC(SUM(Ledger.Value), Filter(ACC IN ("ListOfAccounts"))
But then I would have to create this Account Filter List recursively, but it would be less stress on the DB.

 

(Both Tables Ledger and Account are highly simplified in my example, they are very wide in real life!)

 

Kind regards,

Jörn. (or Joern for US keyboards!)

1 REPLY 1
lbendlin
Super User
Super User

Make sure the empty parents are truly nulls, not empty strings.  Then use a local data model and try to create a calculated column with a PATH statement.  This may not work as generally calculated columns in a Direct Query scenario are limited to the same row.  Can you add the PATH in your data source?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors