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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ggoode
Frequent Visitor

Average count per day per person

I was able to find some similar questions to mine, but have not been able to solve my problem.

Model data:

NameDate
John Smith9/1/2023 5:30:19 PM
John Smith9/1/2023 3:30:19 PM
John Smith 9/2/2023 5:30:18 PM
Jane Smith9/1/2023 3:30:12 PM

 

So what I would want is an average count per day. 

Since John had 2 one day and 1 the other day, his average per day would be 1.5. 

Jane would average 1. 

 

I was thinking I needed to use AVERAGEX, this is my current measure that is not working:

 

Measure = AVERAGEX (
    ALL ( Table1[date] ),
    CALCULATE ( COUNTROWS ( VALUES ( Table1[name] ) ) )
)
 
Any help is appreciated
Thank you
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1706032949114.png

 

 

Expected result measure: = 
VAR _t =
    SELECTCOLUMNS (
        ADDCOLUMNS ( Data, "@dateformat", FORMAT ( Data[Date], "yyyymmdd" ) ),
        Data[Name],
        [@dateformat]
    )
VAR _groupbytable =
    GROUPBY ( _t, [@dateformat], "@countrow", SUMX ( CURRENTGROUP (), 1 ) )
RETURN
    AVERAGEX ( _groupbytable, [@countrow] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
ggoode
Frequent Visitor

This seems to work great, I guess it needed a more complicated measure than I thought. Thank you much

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1706032949114.png

 

 

Expected result measure: = 
VAR _t =
    SELECTCOLUMNS (
        ADDCOLUMNS ( Data, "@dateformat", FORMAT ( Data[Date], "yyyymmdd" ) ),
        Data[Name],
        [@dateformat]
    )
VAR _groupbytable =
    GROUPBY ( _t, [@dateformat], "@countrow", SUMX ( CURRENTGROUP (), 1 ) )
RETURN
    AVERAGEX ( _groupbytable, [@countrow] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors