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
nick-evans
Advocate I
Advocate I

How to get average based off multiple columns?

I have a column in my data that holds a unique value called CaseNumber.

I have another column that lists an OwnerID.

A single OwnerID may be associated with multiple Cases, but a Case can only have one OnwerID.

Here is my Table of data:

testdata.png

I am building a graph to display the average number of cases that occur within a given time frame.

Currently, I can add Count(Distinct) for CaseNumber, and it will tell me how many cases occurred in a given time.

I can add Count(Distinct) for my OwnerID, and it will also show me how many Owners were in that same time.

This effectively means, that the total number of shown cases in a period, were divided amongst the total number of shown Owners.

graph.png

 

In my data, however, not every Owner has the same number of Cases.

This is also shown in the above graph as I outlined.

For my purposes, I need to demonstrate what the average number of cases in a period is, based on the Total Distinct CaseNumbers/Total Distinct OwnerIDs.

 

This would mean, for example, that in August, even though 'Jim' owned 10/11 cases, and 'Tom' owned 1/11, I want the data to represent 5.5 (11 cases /2 owners = 5.5 cases each).

Additionally, the table is just an example. 

I have thousands of records that span many years and have varying categories - in case that impacts possible answers.

 

 

 

I have been pouring through different threads about possibilities done through a new Column, concatenation of a pair of values, I just am not seeing what I need though.

Also, if there's a better description for what I'm trying to do (i.e. better than 'How to get average based off multiple columns') please let me know - this exact title is used on at least one other thread and that thread is something different from what I want, so I figure maybe there's a better way to phrase what I'm after here?

1 ACCEPTED SOLUTION
BILASolution
Solution Specialist
Solution Specialist

Hi @nick-evans

 

I hope it helps

 

Case.png

 

Count Distinct Owners = DISTINCTCOUNT(Table1[OwnerId])

Total Cases = COUNT(Table1[CaseNumber])

Average = DIVIDE([Total Cases];[Count Distinct Owners])

 

 

View solution in original post

3 REPLIES 3
BILASolution
Solution Specialist
Solution Specialist

Hi @nick-evans

 

I hope it helps

 

Case.png

 

Count Distinct Owners = DISTINCTCOUNT(Table1[OwnerId])

Total Cases = COUNT(Table1[CaseNumber])

Average = DIVIDE([Total Cases];[Count Distinct Owners])

 

 

@BILASolution - 

Thanks for the reply.

Your screenshot definitely looks like you were able to get to the type of outcome that I am after.

I tried incorporating your calculations into new columns, but when I setup my table as you show yours, my calculations are crazy now.

The default aggregation for Values appears to be 'Sum', so now that 'Total Cases' has set a value of '19', my Total Cases in the Graph shot up to 209 (should be 19).

Did you change any of your aggregations? 

Unfortunately, the logic of the formulas still is confusing me enough that I'm having a hard time intuiting what else might need to be tweaked here to make your suggestion work as you show it does in your screenshot.

 

new_graph.pngnew_testdata.png

@nick-evans

 

Try to create Count Distinct Owners, Total Cases and Average as Measures instead Calculated Columns.

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.