March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I have created hierarchy structure and count all the child of parent hierarchy.
Diagram:
1
/ \
2 3
/ |\ /\
4 5 6 7 8
/\ /\
9 10 11 12
From the above diagram I need if I select parent "2" then I need to count total Number of child below of "2"(Example: 4,5,9,10 and display count as 4. Note: don't select parent "6" bacause parent "6" has child 9,10) .
Table structure:
Projectkey | ParentKey | Path | length |
1 | 1 | 1 | |
2 | 1 | 1|2 | 2 |
3 | 1 | 1|3 | 2 |
4 | 2 | 1|2|4 | 3 |
5 | 2 | 1|2|5 | 3 |
6 | 2 | 1|2|6 | 3 |
7 | 3 | 1|3|7 | 3 |
8 | 3 | 1|3|8 | 3 |
9 | 6 | 1|2|6|9 | 4 |
10 | 6 | 1|2|6|10 | 4 |
11 | 8 | 1|3|8|11 | 4 |
12 | 8 | 1|3|8|12 | 4 |
Solved! Go to Solution.
Hi @Anonymous,
Based on my test, you could refer to below stpes:
Calculate a calculated column:
Column 3 = PATHITEM('Table1'[Path],2,1)
Create below measure:
Measure 2 = CALCULATE(COUNT(Table1[ParentKey]),FILTER(ALL('Table1'),'Table1'[Column 3]=SELECTEDVALUE('Table1'[ParentKey])&&'Table1'[length]<=3))
Result:
You could also download the pbix file to have a view.
Regards,
Daniel He
Hi @Anonymous,
Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered to close this topic?
Regards,
Daniel He
Hi @Anonymous,
Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered to close this topic?
Regards,
Daniel He
Hi @Anonymous,
Based on my test, you could refer to below stpes:
Calculate a calculated column:
Column 3 = PATHITEM('Table1'[Path],2,1)
Create below measure:
Measure 2 = CALCULATE(COUNT(Table1[ParentKey]),FILTER(ALL('Table1'),'Table1'[Column 3]=SELECTEDVALUE('Table1'[ParentKey])&&'Table1'[length]<=3))
Result:
You could also download the pbix file to have a view.
Regards,
Daniel He
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
21 | |
11 | |
10 | |
9 |
User | Count |
---|---|
48 | |
30 | |
18 | |
17 | |
15 |