cancel
Showing results for
Search instead for
Did you mean:
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

Image 2:

1. List of distinct gear charges

2. Sum of distinct gear charges

3. Correct, expected average of distinct prices.

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.

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
)
)```
4 REPLIES 4
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.

Highlighted
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
)
)```

## Helpful resources

Announcements

#### Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

#### 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.

#### January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

#### Difinity Conference

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

Top Solution Authors
Top Kudoed Authors