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, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
atpbi10
Helper I
Helper I

Average of count distinct values by month

I have the following table

 

NameDateMonthDaySomeValue
John01/01/2021    118
John02/01/2021    122
John02/01/2021    1210
Arnold02/01/2021    124
Sam

02/01/2021

    1299
Sam02/02/2021    227

 

Im trying to figure out a way to count distinct values of a column 'NAME' in a month (so by each day)

Which means that Im trying to calculate how many different people were on average every day in a given month.

So based on that I would get the following result

 

 

 

Month  Daily_Average_of_distinct_names

1            (1+3)/2=2

2            1

 

 

 

I think this is good to create for a measure, am I right? I tried different combinations of AVERAGEX but they are not working at all like for instance:

 

AVERAGEX(VALUES(Sheet1[Month]), DISTINCTCOUNT(Sheet1[NAME]))
 
Any ideas how I could solve this problem?

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @atpbi10 ,

 

Try to create measures like below

d_count_name = CALCULATE( DISTINCTCOUNT('Table'[Name]),FILTER('Table','Table'[weekday]<>2))+0

Measure 2 = CALCULATE(AVERAGEX(VALUES('Table'[Month]),[d_count_name]),REMOVEFILTERS('Table'[weekday]))

V-lianl-msft_0-1614757036952.png

 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hi @atpbi10 ,

 

Try to create measures like below

d_count_name = CALCULATE( DISTINCTCOUNT('Table'[Name]),FILTER('Table','Table'[weekday]<>2))+0

Measure 2 = CALCULATE(AVERAGEX(VALUES('Table'[Month]),[d_count_name]),REMOVEFILTERS('Table'[weekday]))

V-lianl-msft_0-1614757036952.png

 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This worked for me:

AVERAGEX(VALUES(Sheet1[Date]),calculate( DISTINCTCOUNT(Sheet1[NAME])))

But I cant figure out how to filter out "Sunday" and "Saturday" from the column day_of_the_week

Hi @atpbi10 ,

 

The formula I created is to filter day_of_the_week, which is tested to be valid in my sample data.

If the problem persists,could you share the sample pbix via cloud service like onedrive for business?
Please remove any sensitive data before uploading.

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@atpbi10 , Try

 

AVERAGEX(summarize(Table, Table[month], Table[Day],"_1", DISTINCTCOUNT(Sheet1[NAME])),[_1])

 

or
AVERAGEX(VALUES(Sheet1[Date]),calculate( DISTINCTCOUNT(Sheet1[NAME])))

 

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

Seems to be working for me (the second one). Is it possible to add some filter to the AVERAGEX? Like I want to calculte the above, but exclude some observations based on value in another column- lets say DayOfWeek.

So filter out DayOfWeek != Saturday/ Sunday

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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