Forum Discussion

IBrant's avatar
IBrant
Frequent Visitor
2 years ago

Multiple Columns as Rows with Multiple Calculations of those Columns

I have some data in columns as seen below:

 I need this data to appear in a visual like this: 

 I can't figure out how to make the column headers as rows and then get multiple values from these columns, such as average, count and sum. I have only been able to get a single value like average:

Help, please!

6 Replies

  • IBrant , You need to create calculation groups, you have option in model view to create calculation groups

    Create three calculation items and use measures for each of columns. use the Expression function to use data from the line level

     

    Avg = AVERAGEX(Table,SELECTEDMEASURE())
    Count = COUNTX(Table,SELECTEDMEASURE())
    Sum = Sumx(Table,SELECTEDMEASURE())

     

     

    I used these two measure and test

    Qty Line = Sum(Sales[Qty])
    Gross Line = sum(Sales[Gross Sales])

     

     

    Model explorer public preview with calculation group authoring| Measure Slicer: https://youtu.be/VfxfJJ0RzvU

     

    • IBrant's avatar
      IBrant
      Frequent Visitor

      This sounds great, but I don't have a calculation group option.

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi IBrant ,

    Try selecting the matrix. --> format pane -> Value --> switch values to the row --> row headers --> turn off stepped layout:

    Output:

    Is this your expected output?

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

    • IBrant's avatar
      IBrant
      Frequent Visitor

      Hi, Gao,

       

      Thanks for your response but I need it to look more like this: 

      Also, I do not have a row column that inclues all of the categories like your country column. TIA

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi IBrant ,

    Please try:
    1. unpivot these colunms in powerqery:

    2. Group by [Attribute]:

    If you want create a matrix visual, please select these and unpivot

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

    • IBrant's avatar
      IBrant
      Frequent Visitor

      Hi, Gao,

       

      I forgot to mention that these are columns that are calculated based on date columns. So in Power Query the original columns are all dates. I added new columns in table view and wrote formulas to figure out the number of days between the dates and that is how I got those columns.  I apologize, I'm a relatively new Power BI user.