cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Return sum based on row entry

My dataset looks like the following:

ItemSegmentTotal sales
WatermelonExpensive100
StrawberryExpensive200
BananaCheap300
OrangeCheap200

 

I'd like to create a measure that calculates the total sales for that Segment depending on what Item I choose. Here is the desired result:

 

ItemSegment total
Watermelon300
Strawberry300
Banana500
Orange500

 

How do I go about doing this? I basically need a SUM(...) , ALLEXCEPT(... Segment..), but I need to find the correct segment based on the Item (e.g., Watermelon is "Expensive" but Banana is "Cheap").

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: Return sum based on row entry

@hi_potato_salad 

A variable can read the Segment and we can use that in the measure.

Segement Total = 
VAR _Segment = SELECTEDVALUE('Table'[Segment])
RETURN
CALCULATE(
    SUM('Table'[Total sales]),
    ALLEXCEPT('Table','Table'[Segment]),
    'Table'[Segment] = _Segment
)

jdbuchanan71_0-1601580158762.png

 

 

View solution in original post

2 REPLIES 2
Highlighted
Super User IV
Super User IV

Re: Return sum based on row entry

@hi_potato_salad 

A variable can read the Segment and we can use that in the measure.

Segement Total = 
VAR _Segment = SELECTEDVALUE('Table'[Segment])
RETURN
CALCULATE(
    SUM('Table'[Total sales]),
    ALLEXCEPT('Table','Table'[Segment]),
    'Table'[Segment] = _Segment
)

jdbuchanan71_0-1601580158762.png

 

 

View solution in original post

Highlighted
Helper III
Helper III

Re: Return sum based on row entry

Thank you so much! This is awesome. 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Upcoming Events

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors