cancel
Showing results for
Did you mean:
Highlighted
Regular Visitor

## How to calculate an average for a category in a granular table

Hi folks,

I need some urgent help in calculating the average age of case per month and by category from a granular table.

The calculation that i am using is showing me the same value for all months. Visula below.

CALCULATE(
AVERAGEX(
KEEPFILTERS( VALUES('Case'[Case ID])),
AVERAGE('Case'[Case Age])),
FILTER('Case','Case'[New Value] ="Trans"||
'Case'[Old Value] ="Trans"))
As an example my table looks similar to the picture below..

Matrix desired like the below screen grab..

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: How to calculate an average for a category in a granular table

HI @christoR1 ,

You can try to use the following measures if they suitable for your requirement:

```AVG Score =
CALCULATE (
AVERAGE ( Table[Score] ),
ALLSELECTED ( Table ),
VALUES ( Table[PatientID] ),
VALUES ( Table[Patient name] )
)

Count Patient =
CALCULATE (
Countrows(Table),
ALLSELECTED ( Table ),
VALUES ( Table[PatientID] ),
VALUES ( Table[Patient name] )```

If above not help, can you please share some sample data for test?

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI
4 REPLIES 4

## Re: How to calculate an average for a category in a granular table

Hi ChristoR1,

If you see the same values for every row, you always need to check if there is a relationship. In this case between the months and the cases. Can you share your data model?

Cheers, Edgar Walther
Power BI User Group Netherlands
Regular Visitor

## Re: How to calculate an average for a category in a granular table

Hi, there is a one is to many relationship between the case and the calendar table. Also it is unlikely to be the relationship as the other case measures as you can see in the table work just fine except for the measures calculations which is likely to be the dax!

## Re: How to calculate an average for a category in a granular table

OK, let me rephrase this... the relationship is currently not used in your dax formula.

If you share your data model I may be able to help sort it out.  Can you send a small pbix file?

Cheers, Edgar Walther
Power BI User Group Netherlands
Community Support Team

## Re: How to calculate an average for a category in a granular table

HI @christoR1 ,

You can try to use the following measures if they suitable for your requirement:

```AVG Score =
CALCULATE (
AVERAGE ( Table[Score] ),
ALLSELECTED ( Table ),
VALUES ( Table[PatientID] ),
VALUES ( Table[Patient name] )
)

Count Patient =
CALCULATE (
Countrows(Table),
ALLSELECTED ( Table ),
VALUES ( Table[PatientID] ),
VALUES ( Table[Patient name] )```

If above not help, can you please share some sample data for test?

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

Announcements

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!