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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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