Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ERing
Post Partisan
Post Partisan

How can I calculate the Average of Data values across multiple columns?

I have data related to customer survey responses for service representatives. My table visual below displays each Representative and the average of thier scores for each category.

I've been given a new requirement which is to display the Average of scores for each "Score_Categeory". The first 16 columns in the table visual belong to the "Process" Score_Category and the last 4 columns belong to the "Skills" Score_Category.

You'll notice that each Opportunity_ID in my data has two rows. The first row contains scores related to the "Process" Score_Category and the second row containts scores for the "Skills" Score_Category.

My expected output is to have two new measures that I can add as columns to my table visual. The first measure will be the Average of all the "Process" scores for a representative. The second measure will be the Average of all the "Skills" scores for a representative.

I think it's important to note that the measures need to come from the raw data table, not the table visual output. In other words, the new average measures need to be the average of all scores for the relevant Score_Category across all Opportunity_ID's for a representative.

 

Sample Data PBIX 

Table Visual.png


 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @ERing 

 

With the current structure of your data, you will need to have a lengthy measure. The measure below is just for the first two columns

Average of First 2 = 
VAR _tbl =
    FILTER ( 'Average Across Multiple Columns Sample Data', TRUE () )
VAR _analysis =
    SELECTCOLUMNS ( _tbl, "@value", [Analysis] )
VAR _budgeting =
    SELECTCOLUMNS ( _tbl, "@value", [Budgeting] )
VAR _combined =
    UNION ( _analysis, _budgeting )
RETURN
    AVERAGEX ( _combined, [@Value] )

danextian_0-1751347599747.png

If you want a  less lengthy code, you will need to re-shape your data. Please see @pankajnamekar25 's response.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

9 REPLIES 9
v-mdharahman
Community Support
Community Support

Hi @ERing,

Thanks for reaching out to the Microsoft fabric community forum.

It looks like you want to create separate measures that can be added as columns for your table visual. As @Ashish_Mathur@danextian@ajaybabuinturi and @pankajnamekar25 all already responded to your query, kindly go through their responses and check if it solves your issue. Also if your issue has been resolved please mark the helpful reply as solution so that other community members facing the same issue can find the solution easily.

 

I would also take a moment to thank @Ashish_Mathur, @danextian, @ajaybabuinturi and @pankajnamekar25, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.

danextian
Super User
Super User

Hi @ERing 

 

With the current structure of your data, you will need to have a lengthy measure. The measure below is just for the first two columns

Average of First 2 = 
VAR _tbl =
    FILTER ( 'Average Across Multiple Columns Sample Data', TRUE () )
VAR _analysis =
    SELECTCOLUMNS ( _tbl, "@value", [Analysis] )
VAR _budgeting =
    SELECTCOLUMNS ( _tbl, "@value", [Budgeting] )
VAR _combined =
    UNION ( _analysis, _budgeting )
RETURN
    AVERAGEX ( _combined, [@Value] )

danextian_0-1751347599747.png

If you want a  less lengthy code, you will need to re-shape your data. Please see @pankajnamekar25 's response.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks @danextian  I don't mind the code being a little length however my only concern with the approach you outlined is that there is potential for new score columns to be added into the data at some point. If this happens, I would need to remember to update the measure to include the new score columns.

Is there any way to write the code so that it considers the Score_Category or either "Process" or "Skills" rather than the name of the Score column?

That will be the case, DAX cannnot dynamically add new columns and they don't have a grouping you can use to call in a calculation. You will have to explicitly specify them. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
ajaybabuinturi
Solution Sage
Solution Sage

Hi @ERing,
I am seeing there is NO data (Process and Skill) in Score_Category column. Is it expected or should we create a calculated column for Score_Category?

ajaybabuinturi_0-1751346696593.png


Thanks,

 

@ajaybabuinturi The Score Category column will have a value of either Process or Skills. Each Opportunity_ID has two rows. The first row has the scores for Process and the second row has the scores for Skill.

I'm not sure why the values in that column are not showing for you. Can you please try to refresh and see it it populates?
Screenshot 2025-07-01 165857.png

pankajnamekar25
Super User
Super User

Hello @ERing 

Unpivot Score Columns in Power Query

Select all the score columns (both Process and Skills).

Right-click → Unpivot Columns.

Rename

Attribute → Score_Type

Value → Score_Value

Now your table will look like

Representative | Opportunity_ID | Score_Category | Score_Type | Score_Value

 

Create the Measures

Avg_Process_Score =

AVERAGEX(

    FILTER(

        'UnpivotedTable',

        'UnpivotedTable'[Score_Category] = "Process"

    ),

    'UnpivotedTable'[Score_Value]

)

Measure for Skills Avg

Avg_Skills_Score =

AVERAGEX(

    FILTER(

        'UnpivotedTable',

        'UnpivotedTable'[Score_Category] = "Skills"

    ),

    'UnpivotedTable'[Score_Value]

)

Thanks

 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

Thanks @pankajnamekar25 I've followed the steps you provided in the PBIX in the link below. The only issue is that the unpivoted data structure prevents me from creating the table visual with each Score_Type as a column as I have in my original post.

PBIX Unpivoted 
Unpivoted.png

Hi,

You should create a matrix visual with Score_Type in the column section.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.