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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
goalie_
Helper III
Helper III

Getting the sum after an average measure

How would I create a measure for a "Quantity" that takes the sum between selected "Description" selected after it takes the average between "Spec" for a given ID? 

 

I'd like to have a table that looks like if mat1 and mat2 are selected in a slicer, I'd want a table visual that looks like

IDquantity
A0.53
B0.58
C0.33

 

or if mat5 or mat6 are selected

IDquantity
A0.18
B0.12
C0

 

My data is structured as below:

RequestID description   quantity
1Amat10.1
1Amat20.43
1Amat30.21
1Amat40.08
1Amat50.12
1Amat60.06
1Bmat10.25
1Bmat20.33
1Bmat30.2
1Bmat40.1
1Bmat50.12
1Cmat10.26
1Cmat20.07
1Cmat30.63
1Cmat40.04
2Amat10.1
2Amat20.43
2Amat30.21
2Amat40.08
2Amat50.12
2Amat60.06
2Bmat10.25
2Bmat20.33
2Bmat30.2
2Bmat40.1
2Bmat50.12
2Cmat10.26
2Cmat20.07
2Cmat30.63
2Cmat40.04
1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @goalie_  ,

Try the measure  like below:

sum2 = 
CALCULATE (
    SUM ( 'Table'[quantity] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[ID] = MAX ( 'Table'[ID] )
         
    )
)/DISTINCTCOUNT('Table'[Request])

 

vluwangmsft_5-1626946316802.pngvluwangmsft_6-1626946335192.png

 

 

 

Wish it is helpful for you!

 

 

Best Regards

Lucien

 

 

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @goalie_  ,

Try the measure  like below:

sum2 = 
CALCULATE (
    SUM ( 'Table'[quantity] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[ID] = MAX ( 'Table'[ID] )
         
    )
)/DISTINCTCOUNT('Table'[Request])

 

vluwangmsft_5-1626946316802.pngvluwangmsft_6-1626946335192.png

 

 

 

Wish it is helpful for you!

 

 

Best Regards

Lucien

 

 

Vera_33
Resident Rockstar
Resident Rockstar

Hi @goalie_ 

 

While mat5 or mat6 are selected, ID B only has mat5, but you need to divide 2 (mat5 or mat6)? I am using a connected dim table called slicerD which only conatins description

Vera_33_0-1626837486572.png

sum of quantity = COALESCE(DIVIDE( SUM(yourTable[quantity]),COUNTROWS(VALUES(slicerD[description])),0),0)

What do you mean by a connected dimtable? And yes ID B is only meant to contain upto mat5. For a given ID, the number of mats are not always identical. 

Hi @goalie_ 

 

I mean the column in Slicer is not in the same table, but another connected one. The logic how you calculate affects the way you write your measure

 

Vera_33_0-1626917248009.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors