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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Parent-Child hiearchy sql convert

hej

 

i got this sql scrip that i need to use in power bi, but i just cant get it to work in dax

 

UPDATE b SET
[Parent] = ISNULL
(
(
SELECT
MAX(a.[LedgerAccount])
FROM
[dbo].[DIM_LedgerAccounts] a
WHERE
a.[LedgerAccount] < b.[LedgerAccount]
AND a.[Indentation] = b.[Indentation] - 1
AND a.[IncomeBalanceType] = b.[IncomeBalanceType]
AND a.[Company] = b.[Company]
)
,b.[LedgerAccount]
)
FROM
[dbo].[DIM_LedgerAccounts] b
GO

 

can someone help me make a solution

1 ACCEPTED SOLUTION

@Anonymous,

 

Check the post below.

https://community.powerbi.com/t5/Desktop/This-Function/m-p/326489#M145679

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

Try using ISBLANKMAXX and FILTER to add a calculated column.

https://community.powerbi.com/t5/Desktop/conditional-join/m-p/340423#M152404

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hej

 

so i made this dax from your input

 

but it doesnt return an error but just cells with no value

 

i made the column parent in d_ledger account to be equel = 1 because there never is a parent in this data.

 

parent test = IF(('d_ledger account'[Parent])="1";MAXX(
FILTER(
'd_ledger account';
'd_ledger account'[No_] >= RELATED('parent test'[No_])
&& 'd_ledger account'[Indentation] = RELATED('parent test'[Indentation]) - 1
&& 'd_ledger account'[Income_Balance] = RELATED('parent test'[Income_Balance])
);
'd_ledger account'[No_]
);"TEST")
 
can you help me with some more feedback?

@Anonymous,

 

Check the post below.

https://community.powerbi.com/t5/Desktop/This-Function/m-p/326489#M145679

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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