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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
msuser48
Helper I
Helper I

Find average of values in dataset

I have the following dataset:

 

employee_iddatevisitsslicesmonths
101-02-2022 00:00:00121,2511
122-11-2021 00:00:00122,511
201-03-2022 00:00:00213,514
202-06-2021 00:00:0021514
312-12-2022 00:00:00302,2516
313-12-2022 00:00:00302,2516
314-12-2022 00:00:00302,2516

 

Problem 1: How do I find the AVERAGE [visits] number for DISTINCT employee_Ids?

- Output is a measure with the number 21 in this example, since the calculation is (12+21+30) divided by 3.

- [visits] is always the same number per employee_id, so I need to somehow get DISTINCT employee_ids before I find the average.

 

Problem 2: How do I find the AVERAGE [slices] for each month in the [date] column for each employee_id?

- Output is a measure with the number 2,9 since the calculation is (1,25+2,5+3,5+5+2,25) divided by 5.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below measures and the attached pbix file.

 

Problem 1 measure: = 
AVERAGEX ( SUMMARIZE ( Data, Data[employee_id], Data[visits] ), Data[visits] )

 

Problem 2 measure: = 
AVERAGEX (
    SUMMARIZE (
        ADDCOLUMNS ( Data, "@month", MONTH ( Data[months] ) ),
        [@month],
        Data[slices]
    ),
    Data[slices]
)

 

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

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Please check the below measures and the attached pbix file.

 

Problem 1 measure: = 
AVERAGEX ( SUMMARIZE ( Data, Data[employee_id], Data[visits] ), Data[visits] )

 

Problem 2 measure: = 
AVERAGEX (
    SUMMARIZE (
        ADDCOLUMNS ( Data, "@month", MONTH ( Data[months] ) ),
        [@month],
        Data[slices]
    ),
    Data[slices]
)

 

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.