cancel
Showing results for
Did you mean:
Helper I

## Select distinct to get cost

I am trying to create a measure to get the cost for each delivery. My data looks like:

 Deliver Item Delivery Cost A 1 \$1 A 2 \$1 A 3 \$1 A 4 \$1 A 5 \$1 B 6 \$20 B 7 \$20 B 8 \$5 C 9 \$5

So the measure should show the cost as:

A=\$1

B=\$20

C=\$5

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support

## Re: Select distinct to get cost

You may try the measure below.

``````Measure =
SUMX (
VALUES ( 'Table'[Deliver] ),
CALCULATE ( MAX ( 'Table'[Delivery Cost] ) )
)
``````

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
7 REPLIES 7
Super User I

## Re: Select distinct to get cost

Could you confirm if the Delivery Cost for row 8 of your data should be \$20?

Best regards,

Martyn

Proud to be a Super User!

Community Support

## Re: Select distinct to get cost

You may try the measure below.

``````Measure =
SUMX (
VALUES ( 'Table'[Deliver] ),
CALCULATE ( MAX ( 'Table'[Delivery Cost] ) )
)
``````

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Helper I

## Re: Select distinct to get cost

Yes, it should be \$20

Super User I

## Re: Select distinct to get cost

Try this:

``````Cost =
SUMX (
SUMMARIZE (
Table1,
Table1[Deliver],
Table1[Delivery Cost]
),
Table1[Delivery Cost]
)``````

Best regardsm,

Martyn

Proud to be a Super User!

Super User IV

## Re: Select distinct to get cost

Hi,

For B, there are 2 unique costs - 20 and 5.  Why should the answer be 20?

Regards,
Ashish Mathur
http://www.ashishmathur.com
Helper I

## Re: Select distinct to get cost

Yes, my mistake. It should be 20

Super User IV

## Re: Select distinct to get cost

Hi,

Drag Deliver to the Table visual and write these measures

Measure = MIN(Data[Delivery Cost])

Min delivery cost = SUMX(SUMMARIZE(VALUES(Data[Delivery]),VALUES(Data[Delivery],"ABCD",[Measure]),[ABCD])

Drag the second measure to the visual.

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

#### ‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

#### Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

#### Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

#### Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors