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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
unnijoy
Post Partisan
Post Partisan

Average and distinct count

I have a table with Month Counyr and HC. I have country and HC will repeat for all month.

 

But i need to calculate the Average HC based on the distint count of HC.

 

So based onm the below table in need to get the average of two month like 454.75 ( By taking the Distinct HC ). But when i use the avg function i am getting 446.30. 

 

I need a formula that will give me 454.75.

 

 

MonthCountryHC
Jan- 01-2020India234
Jan- 01-2020India234
Jan- 01-2020India234
Jan- 01-2020India234
Jan- 01-2020India234
Jan- 01-2020India234
Jan- 01-2020India234
Jan- 01-2020US343
Jan- 01-2020US343
Jan- 01-2020US343
Jan- 01-2020US343
Jan- 01-2020US343
Jan- 01-2020US343
Feb-01-2020India456
Feb-01-2020India456
Feb-01-2020India456
Feb-01-2020India456
Feb-01-2020India456
Feb-01-2020India456
Feb-01-2020India456
Feb-01-2020US786
Feb-01-2020US786
Feb-01-2020US786
Feb-01-2020US786
Feb-01-2020US786
Feb-01-2020US786
1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

HI @unnijoy ,

 

 

You can try

 

Average Of Country =
AVERAGEX (
    SUMMARIZE (
        'Table',
        'Table'[month],
        'Table'[Country],
        'Table'[HC],
        "DC", SUM ( 'Table'[HC] )
    ),
    'Table'[HC]
)


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @unnijoy, Try this formula:

Avg = AVERAGEX(SUMMARIZECOLUMNS('Table'[Country],'Table'[HC],'Table'[Month]),'Table'[HC])
harshnathani
Community Champion
Community Champion

HI @unnijoy ,

 

 

You can try

 

Average Of Country =
AVERAGEX (
    SUMMARIZE (
        'Table',
        'Table'[month],
        'Table'[Country],
        'Table'[HC],
        "DC", SUM ( 'Table'[HC] )
    ),
    'Table'[HC]
)


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

 

Hi @harshnathani 

 

I tried the formula that you gave. But if HC is same for different month for same country it is taking the HC only once.

 

Eg: Jan 2020 India = 234

and in March 2020 India = 234. At that time the formula is taking 234 only once. Can you tell me wer i went wrong.

 

AVG_HC = AVERAGEX(SUMMARIZE(RAW,RAW[Month],RAW[Country],RAW[HC],"DC",SUM(RAW[HC])),RAW[HC])
 
Raw is TABLE name

The issue is fixed.

 

I change the formula to 

AVG_HC = AVERAGEX(SUMMARIZE(Table ,Table[Country],Table[HC]),Table[HC])
amitchandak
Super User
Super User

@unnijoy , try like

averageX(summarize(Table,Table[month],table[Country HC],"_1",[Distinct count measure]),[_1])
or
averageX(summarize(Table,table[Country HC],"_1",[Distinct count measure]),[_1])

Will check out your blog post!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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