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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
aso_be
Helper I
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

aso_be_0-1659536763798.png


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
                    )

Thanks in advance 🙂 


1 ACCEPTED SOLUTION
aso_be
Helper I
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]
     )

View solution in original post

4 REPLIES 4
aso_be
Helper I
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]
     )

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.

amitchandak
Super User
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'))
    )
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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