Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Have Parent - CHild relationship
where 1Parent with multiple children and their status are provided we need to derive Parent status based on the prefrence of Green-1st, Amber - 2nd and Red-3rd.
So if any Child under that Parent has Green, By default that Parent status will Green etc.
Below is the table data accordingly We Parent Status need to be found.
Parent | Child | Child Status | Parent Status - Expecte output |
P1 | C1 | Red | Green |
P1 | C2 | Amber | Green |
P1 | C3 | Green | Green |
P2 | C4 | Amber | Amber |
P2 | C5 | Amber | Amber |
P2 | C6 | Amber | Amber |
P2 | C7 | Red | Amber |
P3 | C8 | Red | Red |
P3 | C9 | Red | Red |
P3 | C10 | Red | Red |
P3 | C11 | Red | Red |
Hi ,
Please try the following calc column:
Status =
VAR __GREEN =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[Parent] = EARLIER ( 'Table'[Parent] )
&& 'Table'[Child Status] = "Green"
)
)
VAR __AMBER =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[Parent] = EARLIER ( 'Table'[Parent] )
&& 'Table'[Child Status] = "Amber"
)
)
VAR __RED =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[Parent] = EARLIER ( 'Table'[Parent] )
&& 'Table'[Child Status] = "Red"
)
)
RETURN
SWITCH (
TRUE (),
NOT ( ISBLANK ( __GREEN ) ), "Green",
NOT ( ISBLANK ( __AMBER ) ), "Amber",
NOT ( ISBLANK ( __RED ) ), "Red"
)