Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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
jdbuchanan71
Super User
Super User

@Anonymous 

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
jdbuchanan71
Super User
Super User

@Anonymous 

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

 

 

Anonymous
Not applicable

Thank you so much! This is awesome. 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.