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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PBI5851
Helper V
Helper V

Capture average based on slicer

Hello folks, 

please can you help me figure out on how to capture the average days a member has acted based on the ActDate slicer. So when the slicer has the dates, i need to capture the latest row for the PerID within that range and capture the Actdays( no need to sum the previous rows)

ex:

IDPerIDActDateActdays
1A1231/1/20231
2A1231/2/20232
3A1231/3/20233
4A1231/4/20234
5A1231/5/20235
6A1231/6/20236
7A1231/7/20237
8A1231/8/20238
9B1231/6/20231
10B1231/7/20232
11B1231/8/20233
12B1231/9/20234
13C1231/5/20231
14C1231/6/20232
15C1231/7/20233
16C1231/8/20234
17C1231/9/20235
18C1231/10/20236
19C1231/11/20237
20C1231/12/20238

 

So when the slicer is from 1/1/23 to 1/10/23,

the total members are 3

and total actdays are 18 

- A123 @ 8, B123 @ 4 and C123 @6 

This results in an average of 6

 

 

So when the slicer is from 1/4/23 to 1/7/23,

the total members are 3

and total actdays are 12

- A123 @ 7, B123 @ 2 and C123 @ 3 

This results in an average of 3

 

 

So when the slicer is from 1/10/23 to 1/12/23,

the total members are 1

and total actdays are 8

- A123 - 0, B123 -0 and C123 - 8 

This results in an average of 8

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1682134473620.png

 

 

Jihwan_Kim_0-1682134414104.png

 

Count members: = 
COUNTROWS( SUMMARIZE( Data, PerID[PerID]))
Actdays: = 
VAR _lastdatecalendar =
    MAX ( 'Calendar'[Date] )
VAR _lastdateactdate =
    MAXX (
        FILTER (
            ALLSELECTED ( Data ),
            Data[PerID] = MAX ( PerID[PerID] )
                && Data[ActDate] <= _lastdatecalendar
        ),
        Data[ActDate]
    )
RETURN
    IF (
        HASONEVALUE ( PerID[PerID] ),
        CALCULATE ( SUM ( Data[Actdays] ), 'Calendar'[Date] = _lastdateactdate )
    )
Total actdays: = 
SUMX( VALUES( PerID[PerID]), [Actdays:] )
Average actdays: = 
AVERAGEX( VALUES( PerID[PerID]), [Actdays:] )

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1682134473620.png

 

 

Jihwan_Kim_0-1682134414104.png

 

Count members: = 
COUNTROWS( SUMMARIZE( Data, PerID[PerID]))
Actdays: = 
VAR _lastdatecalendar =
    MAX ( 'Calendar'[Date] )
VAR _lastdateactdate =
    MAXX (
        FILTER (
            ALLSELECTED ( Data ),
            Data[PerID] = MAX ( PerID[PerID] )
                && Data[ActDate] <= _lastdatecalendar
        ),
        Data[ActDate]
    )
RETURN
    IF (
        HASONEVALUE ( PerID[PerID] ),
        CALCULATE ( SUM ( Data[Actdays] ), 'Calendar'[Date] = _lastdateactdate )
    )
Total actdays: = 
SUMX( VALUES( PerID[PerID]), [Actdays:] )
Average actdays: = 
AVERAGEX( VALUES( PerID[PerID]), [Actdays:] )

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.