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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
andrew_hardwick
Helper III
Helper III

average of column in table

I am trying to display the average of a column within a table. My table contains information has shown below:

Capture.PNG

 

The IncidentToTaskTime2 column is a measure which looks at the difference betweeen Incident OpenDateTime and Task OpenDateTime, displayed in hours.


However the total at the bottom displays 1. This is clearly not the sum of that column, so I am not sure what it is displaying. Either way, I would like to show the average of the column there. I cannot see any options for this, can someone help?

1 ACCEPTED SOLUTION

Hi @andrew_hardwick,

 

Your problem in this measure is that the Name on the first column has a duplicated value so whern calculating average it only get a 36 one time and divides by 5 not 6, is the second name column compose by unique ID's? If so select that column for your measure, or another one that as unique values, even if it's not on your table visual.

 

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

8 REPLIES 8
MFelix
Super User
Super User

Hi @andrew_hardwick,

 

When calculating a measure this is based on context so when you add it to a table visual it will calculate based on the line data, when you go to the subtotals/ totals line this is based on the total information so when making averages or max values you will get odd number because it considers the full data.

 

You need to add a measure like this:

 

average total line =
IF (
    HASONEVALUE ( Table[Name] );
    [IncidenToTaskTime2];
    AVERAGEX ( ALLSELECTED ( Table[Name] ); [IncidenToTaskTime2] )
)

In this measure I'm overwriting the Incident Measure by another measure that makes the Average line by line of the Incident Measure.

 

Basically is looking at the data and if it has a name then returns the Measure, if you don't have the name it creates a "virtual table" with all the measure values and then makes the average of those values.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix

 

I tried this and it doesn't seem to have worked exactly as expected. I created the measure as below:

 

average total line =
IF (
    HASONEVALUE(Incident[Name]),
    [IncidentToTaskTime2],
    AVERAGEX ( ALLSELECTED (Incident[name]), [IncidentToTaskTime2] )
)

 

I then added this to my table and it displays as shown:

 

Capture.PNG

 

Which seems almost correct, but when I check the same values in Excel and do an average I get a different result.

 

1
1
1
23
36
36
16.33333

 

So the averge doesn't appear to have calculated correctly.

Hi @andrew_hardwick,

 

Your problem in this measure is that the Name on the first column has a duplicated value so whern calculating average it only get a 36 one time and divides by 5 not 6, is the second name column compose by unique ID's? If so select that column for your measure, or another one that as unique values, even if it's not on your table visual.

 

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix. Indeed you are correct, that is what the issue is.

 

Ideally I would only have one Name ID in the first column. The reason it is showing 2 is that there are 2 tasks linked to the unique ID in the first Column. In actual fact, what I would like is to only have the task with the earliest date shown. This would remove the average error and make the report more accurate.

 

Do you also know how I can limit the results to show the first Task linked to the ID? I have built a relationship between the 2 table using the Unique ID shown in the first Column.

Try to change the summarization on the column you want to the first / minimum on the table visual.


Regards,
MFelix

Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



I tried selecting Name on the first column, but it does not make any difference. It still shows the duplicate entry.

Hi @MFelix. I managed to get rid of the duplicate by selecting first on the 3rd column too, however the average still appears to be wrong.

 

The screenshot below shows the output, but in Excel I calculate the average as 38.85. I added another measure myself which came out at 36.2, but is still not accurate.

 

IncidentToTaskTime2 average per Ticket_Type__c =
AVERAGEX(Incident,[IncidentToTaskTime2])

 

Capture.PNG

 

The date is shown below.

 

Any ideas?

 

First NameIncident OpenDateTimeFirst NameTask OpenDateTimeIncidentToTaskTime2average total lineIncidentToTaskTime2 average per Ticket_Type__c
141780416/09/2018 07:579814216/09/2018 08:33111
141782116/09/2018 08:469814316/09/2018 09:12111
141784816/09/2018 10:459814416/09/2018 11:10111
141786516/09/2018 11:269819617/09/2018 10:22232323
141797117/09/2018 00:469816217/09/2018 04:50444
141804117/09/2018 02:229898725/09/2018 14:16204204204
141804717/09/2018 02:419815917/09/2018 02:42000
141807717/09/2018 03:269831118/09/2018 03:31242424
141808117/09/2018 03:339820817/09/2018 13:29101010
141813817/09/2018 05:069816417/09/2018 06:26111
141814217/09/2018 05:099818117/09/2018 08:52333
141821617/09/2018 06:099816317/09/2018 06:09000
141823417/09/2018 06:199816717/09/2018 07:24111
141837017/09/2018 07:319818317/09/2018 09:26222
141837217/09/2018 07:329816817/09/2018 07:32000
141839117/09/2018 07:399830418/09/2018 01:36181818
141841417/09/2018 07:469818517/09/2018 09:50222
141841617/09/2018 07:469818617/09/2018 09:50222
141841717/09/2018 07:489818717/09/2018 09:50222
141842117/09/2018 07:499818817/09/2018 09:50222
141842517/09/2018 07:509817117/09/2018 07:50000
141842917/09/2018 07:539817817/09/2018 08:28111
141844417/09/2018 08:039833118/09/2018 08:41242424
141844517/09/2018 08:049817417/09/2018 08:04000
141844617/09/2018 08:049833218/09/2018 08:42242424
141845017/09/2018 08:069833318/09/2018 08:43242424
141845217/09/2018 08:069833418/09/2018 08:45242424
141846417/09/2018 08:109817517/09/2018 08:12000
141846417/09/2018 08:109854820/09/2018 09:16737373
141847717/09/2018 08:169817617/09/2018 08:16000
141854717/09/2018 08:379818017/09/2018 08:37000
141860517/09/2018 08:589845419/09/2018 11:56515151
141860917/09/2018 09:019819317/09/2018 10:07111
141862317/09/2018 09:069819817/09/2018 10:52111
141866417/09/2018 09:229819717/09/2018 10:32111
141867417/09/2018 09:279843919/09/2018 08:09474747
141868917/09/2018 09:359818417/09/2018 09:39000
141869417/09/2018 09:409830618/09/2018 02:28171717
141872717/09/2018 10:049852220/09/2018 06:43686868
141873217/09/2018 10:089833518/09/2018 08:46222222
141873817/09/2018 10:139930328/09/2018 02:19256256256
141875117/09/2018 10:219821317/09/2018 13:42333
141875717/09/2018 10:259873921/09/2018 15:15101101101
141876717/09/2018 10:289833618/09/2018 08:47222222
141883617/09/2018 11:119965003/10/2018 06:27379379379
141884217/09/2018 11:199855520/09/2018 10:40717171
141887617/09/2018 11:409834418/09/2018 09:55222222
141888817/09/2018 11:499837218/09/2018 15:20282828
141890317/09/2018 11:589819917/09/2018 12:19111
141891117/09/2018 12:029895225/09/2018 07:45187187187
141902017/09/2018 13:109820717/09/2018 13:10000
141919317/09/2018 14:309822017/09/2018 14:32000
141921817/09/2018 14:429822917/09/2018 15:44111
141924817/09/2018 14:579898425/09/2018 13:55191191191
141928017/09/2018 15:259831618/09/2018 06:05151515
141931317/09/2018 15:469870221/09/2018 07:33888888
141932317/09/2018 15:519854120/09/2018 08:37656565
141934317/09/2018 16:169823017/09/2018 16:20000
141935617/09/2018 16:339854720/09/2018 09:03656565

Hi @andrew_hardwick,

 

Is it possible to share a sample of the PBIX file, maybe by private message?

 

Regards,

MFelix

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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