Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
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:
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:
I would greatly appreciate your help with this!
Liz
Solved! Go to Solution.
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] )
)
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.
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 45 | |
| 38 | |
| 34 | |
| 21 | |
| 17 |
| User | Count |
|---|---|
| 65 | |
| 62 | |
| 31 | |
| 26 | |
| 25 |