Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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 DiabetesCHFAsthmaSleep Apnea 
xxxx1XX X
xxxx2 XX 
xxxx3X   
xxxx4XXXX
xxxx5  XX
xxxx6 X  
xxxx7XX  
xxxx8XXXX
xxxx9    
     

 

What im getting 

Patient DiabetesCHFAsthmaSleep Apnea 
xxxx1X   
xxxx1 x  
xxxx1   x
xxxx2 X  
xxxx2  X 
xxxx3x   
xxxx4x   
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. 

  • Anonymous's avatar
    Anonymous
    3 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

  • Anonymous's avatar
    Anonymous
    Not 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.