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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Sarath5c8
Frequent 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.

ParentChildChild StatusParent Status - Expecte output
P1C1RedGreen
P1C2AmberGreen
P1C3GreenGreen
P2C4AmberAmber
P2C5AmberAmber
P2C6AmberAmber
P2C7RedAmber
P3C8RedRed
P3C9RedRed
P3C10RedRed
P3C11RedRed

 

1 REPLY 1
danextian
Super User
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"
    )

danextian_1-1699093061513.png

 

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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