cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper I

## How to get average of countrows in a table as total

Hi guys,

After being a reader of this community for weeks, I would need some help for this unanswered question.

It's quite simple, but I couldn't find the solution. I would like to get the average as the total of the table of a measure which counts the number of rows.

Here is my data sample

I would like the average next to the red arrow.

My measure are

nb_days_active =
AVERAGEX(
'blabla,
CALCULATE(Countrows('blabla'))
)

nb_days_stock =
CALCULATE(
AVERAGEX('blabla',COUNTROWS('blabla')),
'blabla'[quantity_stock_internal]>0
)

1 ACCEPTED SOLUTION
Helper I

I found the solution. I needed to add the countrows within my summarize

AVERAGEX(
SUMMARIZE('blabla','blabla'[id],"active_days",COUNTROWS('blabla')),
[active_days]
)
4 REPLIES 4
Helper I

I found the solution. I needed to add the countrows within my summarize

AVERAGEX(
SUMMARIZE('blabla','blabla'[id],"active_days",COUNTROWS('blabla')),
[active_days]
)
Community Support

I am so glad to hear that your problem has been solved . Please consider Accept it as the solution to help the other members find it more quickly.

Super User

@aso_be , This average need a level/column/group by. The one used in visual '

nb_days_active =
AVERAGEX(
values('blabla'[Column]) ,
CALCULATE(Countrows('blabla'))
)

or

nb_days_active =
AVERAGEX(
summarize('blabla','blabla'[Column],'blabla'[Column2]) ,
CALCULATE(Countrows('blabla'))
)
Helper I

Thanks @amitchandak for your fast reply. I tried both, but still, the total is a sum. 😞

What am I doing wrong?

nb_days_active =
//if a product is active, there is a row in the table every day, if the product has got stock

nb_days_active =
AVERAGEX(
SUMMARIZE('blabla','blabla'[id],'blabla'[snapshot_date]),
Countrows('blabla')
)

or

nb_days_active =
AVERAGEX(
SUMMARIZE('blabla','blabla'[id]),
Countrows('blabla')
)

The first row of my table is the ID (of the product), it still doesn't average the total.

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors