cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DataUsurper Regular Visitor
Regular Visitor

Calculating The Avg Price from Distinct Set of Prices

Hello PBI Guru's,

 

I am attempting to calculate the average price of an item where the $ > 0 and averaged only by the distinct price and not the number of lines (records).

Image 1: Data structure

PBI2.png

 

Image 2:

1. List of distinct gear charges

2. Sum of distinct gear charges

3. Correct, expected average of distinct prices.

PBI1.png

 

I've searched and founda few similar posts but was not able to replicate that correct answer. Any help is greatly appreciated.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Anonymous
Not applicable

Re: Calculating The Avg Price from Distinct Set of Prices

Calc :=
AVERAGEX (
    SUMMARIZE ( 'Table', 'Table'[ProductName], 'Table'[Price] ),
    'Table'[Price]
)

Try this, just remplace 'Table' with your table name.  This will create the unique list of products and prices, then using averagex, iterate over these to create the average price.

View solution in original post

Anonymous
Not applicable

Re: Calculating The Avg Price from Distinct Set of Prices

CALCULATE
(
	AVERAGEX
	(
		SUMMARIZE
		(
			'Table'
			,'Table'[ProductName]
			,'Table'[Price]
		)
		,'Table'[Price]
	)
	,FILTER
	(
		VALUES('Table'[Price])
		,NOT(ISBLANK('Table'[Price])) && 'Table'[Price] <> 0 
	)
)

View solution in original post

4 REPLIES 4
vanessafvg Super Contributor
Super Contributor

Re: Calculating The Avg Price from Distinct Set of Prices

@DataUsurper  any chance you can share the data in text not image?


Did I answer your question? Mark my post as a solution.
Proud a to be a Datanaut!
Anonymous
Not applicable

Re: Calculating The Avg Price from Distinct Set of Prices

Calc :=
AVERAGEX (
    SUMMARIZE ( 'Table', 'Table'[ProductName], 'Table'[Price] ),
    'Table'[Price]
)

Try this, just remplace 'Table' with your table name.  This will create the unique list of products and prices, then using averagex, iterate over these to create the average price.

View solution in original post

DataUsurper Regular Visitor
Regular Visitor

Re: Calculating The Avg Price from Distinct Set of Prices

Thank you, that's the format. I was trying it with the Averagex/Summarize swapped. Is there a place where I can only include > 0 records? No blanks or 0s

Anonymous
Not applicable

Re: Calculating The Avg Price from Distinct Set of Prices

CALCULATE
(
	AVERAGEX
	(
		SUMMARIZE
		(
			'Table'
			,'Table'[ProductName]
			,'Table'[Price]
		)
		,'Table'[Price]
	)
	,FILTER
	(
		VALUES('Table'[Price])
		,NOT(ISBLANK('Table'[Price])) && 'Table'[Price] <> 0 
	)
)

View solution in original post

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)