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

Highlighted
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
Super User I
Super User I

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

Highlighted
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
Coming Soon: T-Shirt Design Contest

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors