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
abukapsoun
Post Patron
Post Patron

Calculate distinct

Hi,

I need your expertise please

 

I have the following table

 

HCPrice
X350
X350
X350
Y400
Y400
Z600
Z600

 

 

How can I compute the average price taking into consideration distinct HCs and not all of them?

 

Thanks,

 

1 ACCEPTED SOLUTION

@abukapsoun - Seems like this should be:

Measure 29 = 
    VAR __Table = SUMMARIZE('Table (29)',[HC],"Average",AVERAGE([Price]))
RETURN
    AVERAGEX(__Table,[Average])

Attached PBIX below sig, Page 29.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

@abukapsoun , Try a measure like

averageX(values(Table[HC]), max(Table[Price]))

or

averageX(Summarize(Table, Table[HC],"_1", max(Table[Price])), [_1])

Hi,

 

both did not work

 

@abukapsoun , expected output.

 

refer if file after signature can help

I am expecting (350+400+600)/3

 

@abukapsoun ,Please find the attached file after the signature . I think that 450 . refer Avg2, Avg 3

Still not working 😞

@abukapsoun - Seems like this should be:

Measure 29 = 
    VAR __Table = SUMMARIZE('Table (29)',[HC],"Average",AVERAGE([Price]))
RETURN
    AVERAGEX(__Table,[Average])

Attached PBIX below sig, Page 29.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@abukapsoun , what is not working, I can see 450 in card, do you need that at each line ?

 

Calculate(averageX(Summarize(Table, Table[HC],"_1", max(Table[Price])), [_1]) , all(Table))

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.