Forum Discussion
Create bins or groups as a column
My goal is below to have a patient ID and then what catorgies or DX that are assoicated to their chart.
| Patient | Diabetes | CHF | Asthma | Sleep Apnea |
| xxxx1 | X | X | X | |
| xxxx2 | X | X | ||
| xxxx3 | X | |||
| xxxx4 | X | X | X | X |
| xxxx5 | X | X | ||
| xxxx6 | X | |||
| xxxx7 | X | X | ||
| xxxx8 | X | X | X | X |
| xxxx9 | ||||
What im getting
| Patient | Diabetes | CHF | Asthma | Sleep Apnea |
| xxxx1 | X | |||
| xxxx1 | x | |||
| xxxx1 | x | |||
| xxxx2 | X | |||
| xxxx2 | X | |||
| xxxx3 | x | |||
| xxxx4 | x | |||
| xxxx4 | x | |||
| xxxx4 | x | |||
| xxxx4 | x | |||
I am trying to avoid creating a table for each DX because it will just grow. My data is in three tables.
Table one- Patient Data
Table two- Every possible DX code
table three- Appointment encounters.
Im at a lost now i feel like this should be a simple table to construct.
- Anonymous3 years ago
Hi Anonymous ,
Please try below operations in Power Query Pane:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WqgACQyUdpQggVoDjWB2EDEikAqeMAlwFTMYIKhKBoccISX0Eiowxih3IMiZ4ZbC7zQTFXbhkoK6OBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Patient " = _t, Diabetes = _t, CHF = _t, Asthma = _t, #"Sleep Apnea " = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Patient ", type text}, {"Diabetes", type text}, {"CHF", type text}, {"Asthma", type text}, {"Sleep Apnea ", type text}}), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Patient "}, "Attribute", "Value"), #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value", List.Max) in #"Pivoted Column"Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi Anonymous ,
Please try below operations in Power Query Pane:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WqgACQyUdpQggVoDjWB2EDEikAqeMAlwFTMYIKhKBoccISX0Eiowxih3IMiZ4ZbC7zQTFXbhkoK6OBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Patient " = _t, Diabetes = _t, CHF = _t, Asthma = _t, #"Sleep Apnea " = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Patient ", type text}, {"Diabetes", type text}, {"CHF", type text}, {"Asthma", type text}, {"Sleep Apnea ", type text}}), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Patient "}, "Attribute", "Value"), #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value", List.Max) in #"Pivoted Column"Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.