Forum Discussion

jdugas's avatar
jdugas
Advocate I
9 years ago
Solved

Sum based on Different Column

Is it possible to create a calculated column to sum all column names that begin with "ANSWERx" where "x" is either a single digit or double digit? I'm trying to find a score for survey results.

  • jdugas

     

    Hello,

    People here have given great ideas. This question is complicated. Maybe there is no easy answer. You can try this.

    1. Add an index to the table in Query Editor.
    2. Choose three columns with CTRL. Then click Unpivot Columns.
    3. Create a measure.

    Average =

    SUM ( Table1[Value] ) / COUNT ( Table1[Value] )

     

     

11 Replies

  • What I would suggest doing is to rather create your column in the Query Editor.

     

    In the Query Editor it has got a lot more functionality in order to create the column you require.

     

    And then once you have your new column created you can very easily create your measure.

     

    If you need some assistance, can you provide a sample of data?

    • jdugas's avatar
      jdugas
      Advocate I

      Not following you.

       

      Sample data

       

      Date              Answer1        Answer2      Answer3

      1/1/2017       4                    4                  5

      1/1/2017       3                    4                  0

       

      The above example would create a new calculated column which would sum up the columns "Answer1, Answer 2, Answer3" perhaps using a wildcard like "Answer?"

       

      Hope that makes sense.

      Jeremy

      • GilbertQ's avatar
        GilbertQ
        Super User

        hi jdugas

         

        Do your columns always have Answer1, Answer2, Answer3 etc?


        If so you can create the following measure.

         

        Answer Total = sum('TableName'[Answer1]) + sum('TableName'[Answer2]) + sum('TableName'[Answer3])