Forum Discussion

mahmoud's avatar
mahmoud
Helper I
9 years ago
Solved

Create Matrix From Five Columns

I have five questions, each question has four awnsers options(as appear in the picture down). In Excel, I used countif function to create the table and get the values. I would to create same table in Power BI?

Is that posible? After that create a chart! :)

 

Thanks for your support in advans!

 

  • Hi mahmoud,

    Assiming your data is in the format you present In the query view you need to select all the questions columns and unpivoted them you will get a table with 3 columns:
    Answers type
    Attribute - questions
    Count

    Then in the matrix visual put the columns in the index below:
    Answers type - Rows
    Attribute - columns
    Count - values

    This should give what you.want.

    Regards,
    MFelix


  • Hi mahmoud,

     

    I was looking at your data and I would do a simple treatment of the information. I would take all the reply and ID column into one table and unpivoted them so would have a table with 3 columns: ID, Question, answer them would do a table with the rest of the question (age, start end date, ...) also with ID and keep it as is and then do the relationship between both tables by ID this would give you the reply that you need for your visuals but also a base with additional information to make the age of respondent visuals, etc...

     

    Regards,

    MFelix

  • Hi mahmoud,

     

    This is one thing I noticed in your data, in your replies you have columns that are text and others that are numbers, problably you should divide between two tables one with the text values and another with the number values that way you could do the statistic analysis in you data and the quality also.

     

    Regards,

    MFelix

7 Replies

  • Hi mahmoud,

    Assiming your data is in the format you present In the query view you need to select all the questions columns and unpivoted them you will get a table with 3 columns:
    Answers type
    Attribute - questions
    Count

    Then in the matrix visual put the columns in the index below:
    Answers type - Rows
    Attribute - columns
    Count - values

    This should give what you.want.

    Regards,
    MFelix


    • mahmoud's avatar
      mahmoud
      Helper I

      Hi MFelix

      Sorry to back to you late.

      I have a question, after unpivot the columns, it will create many rows and that will effect on the other columns counted values ( the number of rows equal to number of new rows from unpivoted columns).

       

      So if I have 30 culomns, and I would to unpivot some culomns and count the other ( I would to unpivot columns from 5 to 10, then the columns 11 to 14, then 16 to 20, and then 23 to 27). At the same time I have to count the values in column 1 and have charts from other columns(2,3,4,6,15,22,...etc).

       

      As I tried for first time, the numbers of rows were equal to the number of rows in unpivoted columns, but that effected in the correct number.

       

      I hope I am clear and get best way to fix that.

      Thanks for you support!

      Mahmoud

       

      • MFelix's avatar
        MFelix
        Super User

        Hi mahmoud,

         

        You are correct when you say that there will be an increase on the other rows, because for each row you have it will multiplied bty the number of columns you unpivot.

         

        I don't know how your data is set up but depending on the result you want/need you probably will have to do some further query changes or change the way your charts are calculated.

         

        Without further information I cannot help you in the right way.

         

        MFelix