Forum Discussion
Sarath5c8
2 years agoFrequent Visitor
Need to prioritize and get the reference based column
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 |
1 Reply
- danextian
Super User
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" )