Forum Discussion

bdoiron's avatar
bdoiron
Frequent Visitor
9 years ago

Crosstab Query

 

Hello all, I have a table that is unnormalized that I am trying to make a table visual from. Its values go across horizontal and I need them vertical. I can unpivot all the columns but that doesnt work. One column is a Safe count and the next is an At risk count. These counts pertain to one item say "Body position". This is what my table looks like

 

Body position Safe --- Body position At Risk ----- Slips Safe ----  Slip At Risk     and so on........   around 20 columns

          10                                  5                                    13                     7

 

I need it to look like this:                                         I can unpivot all and I get this:

 

Descr                         Safe    At Risk                      

Body position              10        5                                 Body position Safe           10

Slips                             13        7                                 Body position At Risk         5

  ***************                                                           Slips Safe                         13     

                                                                                    Slips At Risk                       7

 

  Thanks for any help !!!!!!!!!1!!!!1      

 

 

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Select all of your columns, click "Transform" tab in Query Editor and then choose "Unpivot Columns". You will end up with Attribute Value pairs and then you could create measures to do the calculations regarding risk and safe.

  • v-caliao-msft's avatar
    v-caliao-msft
    Microsoft Employee

    bdoiron,

     

    I can unpivot all and I get this:
    Body position Safe           10

    Body position At Risk         5

    Slips Safe                         13     

    Slips At Risk                       7

     

    If you can get this result, you can split the first column into two colums, and then use matrix visual to get your expected results.

    Descr                         Status                   Count

    Body position           Safe                        10

    Body position           At Risk                    5

    Slips                         Safe                         13     

    Slips                         At Risk                      7

     

    Regards,

    Charlie Liao