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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
lizman1111
New Member

Help w/ Calculated Column Formula

Hi all,

 

I'm hoping someone can help me with writing a formula for a calculated column.  I work with patient data and would like to have a column in a table that lists the 1st site of service for each patient (meaning where they were discharged to after surgery).  Here's a simple rendering of the current table:

lizman1111_1-1594227476162.png

You can see the same Case ID is listed on mutliple rows for each event order.  What I would like to add is a column for 1st site of service (event order of 1) that returns the patient's 1st Facility Type for all rows of case ID's.  See example below:

lizman1111_2-1594227739960.png

I would greatly appreciate your help with this!

 

Liz

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@lizman1111 

Give this a try as your calculated column.

 

1st Site of Service = 
VAR _EventOrder =
    CALCULATE (
        MIN ( 'Table'[Event_Order] ),
        ALLEXCEPT ( 'Table', 'Table'[Case_ID] )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Facility_Type] ),
        'Table'[Event_Order] = _EventOrder,
        ALLEXCEPT ( 'Table', 'Table'[Case_ID] )
    )

If your first Event_Order is always 1 you could use.

1st Site of Service = 
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Facility_Type] ),
        'Table'[Event_Order] = 1,
        ALLEXCEPT ( 'Table', 'Table'[Case_ID] )
    )

 

 

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

@lizman1111 

Give this a try as your calculated column.

 

1st Site of Service = 
VAR _EventOrder =
    CALCULATE (
        MIN ( 'Table'[Event_Order] ),
        ALLEXCEPT ( 'Table', 'Table'[Case_ID] )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Facility_Type] ),
        'Table'[Event_Order] = _EventOrder,
        ALLEXCEPT ( 'Table', 'Table'[Case_ID] )
    )

If your first Event_Order is always 1 you could use.

1st Site of Service = 
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Facility_Type] ),
        'Table'[Event_Order] = 1,
        ALLEXCEPT ( 'Table', 'Table'[Case_ID] )
    )

 

 

@jdbuchanan71 Yes!  The 2nd formula worked because the 1st site of service is always 1.  It can also be blank so I added an "IF(ISBLANK(..." statement.  Thank you!  I am researching the ALLEXCEPT function now...very helpful.

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.