Forum Discussion
Returning a value when considering multiple criteria in an array
Hello,
Basically I have a table of Dates, Patients, Providers, and Procedure Codes. I need to return another value if a Patient Visit on a particular Date, with a particular Provider has 2 specific Procedure Codes/Categories.
Svc_DateClinic IDPatient IDProvider IDProcedure Code IDProcedure Category ID
| 4/1/2021 | Denver | 1234 | James | 26 | Non-Covid |
| 4/1/2021 | Denver | 1234 | James | 27 | Non-Covid |
| 4/1/2021 | Denver | 1234 | James | 28 | Non-Covid |
| 4/2/2021 | Colorado Springs | 2234 | Andrews | 02 | Office Visit |
| 4/2/2021 | Colorado Springs | 2234 | Andrews | 02 | Office Visit |
| 4/2/2021 | Colorado Springs | 2234 | Andrews | 29 | Covid Test |
| 4/3/2021 | Aurora | 5545 | Grant | 09 | Covid Test |
| 4/3/2021 | Aurora | 5545 | Grant | 30 | Office Visit |
| 4/3/2021 | Aurora | 5545 | Grant | 31 | Office Visit |
| 4/4/2021 | Parker | 2234 | Andrews | 02 | Office Visit |
| 4/4/2021 | Parker | 2234 | Andrews | 07 | Office Visit |
| 4/4/2021 | Parker | 2234 | Andrews | 32 | Office Visit |
| 4/4/2021 | Denver | 5545 | James | 49 | Covid Vaccine |
| 4/4/2021 | Denver | 5545 | James | 50 | Office Visit |
| 4/5/2021 | Denver | 1234 | Andrews | 40 | Covid Vaccine |
If a visit contains an Office Visit & a Covid Test, then I need to return a text. Similarly with visits that are only Office Visits and only Covid Vaccines.
Please let me know if you have any questions!
Hi jcarb0321 ,
You can create this calculate column:
A = VAR _count = CALCULATE ( DISTINCTCOUNT ( 'Table'[Procedure Category ID] ), FILTER ( ALL ( 'Table' ), 'Table'[Procedure Category ID] <> "Non-Covid" && 'Table'[Svc_Date] = EARLIER ( 'Table'[Svc_Date] ) && 'Table'[Patient ID] = EARLIER ( 'Table'[Patient ID] ) && 'Table'[Provider ID] = EARLIER ( 'Table'[Provider ID] ) ) ) RETURN SWITCH ( TRUE (), _count >= 2, "Office Visit and Covid Test", _count = 1, "Only " & [Procedure Category ID] )Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- FowmySuper User
jcarb0321
Please add the following column and check:Visit Type = var __filter = ALlEXCEPT(Table2,Table2[Svc_Date],Table2[Patient ID],Table2[Provider ID]) var __table = CALCULATETABLE(VALUES(Table2[Procedure Category ID]),__filter) var __all = CALCULATE( COUNTROWS(Table2), __filter) VAR __testoffice = COUNTROWS(FILTER(__table , Table2[Procedure Category ID] in {"Covid Test", "Office Visit"} )) >= 2 VAR __office = CALCULATE( COUNTROWS(Table2), __filter, Table2[Procedure Category ID] = "Office Visit") = __all VAR __vaccine = CALCULATE( COUNTROWS(Table2),__filter, Table2[Procedure Category ID] = "Covid Vaccine") = __all return SWITCH( TRUE(), __testoffice=TRUE(),"Office Visit and Test", __office=TRUE(),"Office Visit only", __vaccine=TRUE(), "'Vaccine Only" ) - v-yingjlCommunity Support
Hi jcarb0321 ,
You can create this calculate column:
A = VAR _count = CALCULATE ( DISTINCTCOUNT ( 'Table'[Procedure Category ID] ), FILTER ( ALL ( 'Table' ), 'Table'[Procedure Category ID] <> "Non-Covid" && 'Table'[Svc_Date] = EARLIER ( 'Table'[Svc_Date] ) && 'Table'[Patient ID] = EARLIER ( 'Table'[Patient ID] ) && 'Table'[Provider ID] = EARLIER ( 'Table'[Provider ID] ) ) ) RETURN SWITCH ( TRUE (), _count >= 2, "Office Visit and Covid Test", _count = 1, "Only " & [Procedure Category ID] )Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.