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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculating Average of a sum of subtotal

All,

 

I am trying to figure out how to calculate an average of a sum of a subtotal (I might be say this wrong - apologies). 

 

1. Date will be the slicer

2. I want to show a descending list of partners with total units. I have to take the average of the units over multiple days.

 

for example:

p2 - 420

p3 - 340

p1 - 210

 

3. Once i show the above in a bar chart, I need an ability to drill into the market level.

 

DatePartnerMarketUnit
1/1/2020p1New York10
1/1/2020p1San Fran200
1/1/2020p2New York20
1/1/2020p2San Fran400
1/1/2020p3New York300
1/1/2020p3San Fran40
1/2/2020p1New York10
1/2/2020p1San Fran200
1/2/2020p2New York20
1/2/2020p2San Fran400
1/2/2020p3New York300
1/2/2020p3San Fran40

 

I checked the forum for a solution. I am not able to figure this out and appreciate any helping hand.

 

Thanks

Sundar

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks everyone for your assistance.

 

I revised the suggestion provided my @amitchandak and this worked for me. Thank You!

 

AvgUnit =
AVERAGEX (
SUMMARIZE('Table1', 'Table1'[Partner], 'Table1'[Date]),
CALCULATE(sum('Table1'[Unit]))
)

View solution in original post

4 REPLIES 4
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

Please try like this:

AVG_Unit =
VAR total_unit =
    CALCULATE ( SUM ( 'Table'[Unit] ), ALLEXCEPT ( 'Table', 'Table'[Partner] ) )
VAR days =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Date] ),
        ALLEXCEPT ( 'Table', 'Table'[Partner] )
    )
RETURN
    DIVIDE ( total_unit, days )


AVG_Market =
VAR total_unit =
    CALCULATE ( SUM ( 'Table'[Unit] ), ALLEXCEPT ( 'Table', 'Table'[Market] ) )
VAR days =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Date] ),
        ALLEXCEPT ( 'Table', 'Table'[Market] )
    )
RETURN
    DIVIDE ( total_unit, days )


Measure = IF(ISFILTERED('Table'[Partner]),[AVG_Unit],[AVG_Market])

1.gif

For more details, please see the attachment.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

I think you need to Avg of Sum. Refer

https://community.powerbi.com/t5/Desktop/SUM-of-AVERAGE/td-p/197013

 

You can also try

averagex(summarize(Table,table[Date],table[Partner],"_sum",table[Unit]),[_sum])

Anonymous
Not applicable

Thanks everyone for your assistance.

 

I revised the suggestion provided my @amitchandak and this worked for me. Thank You!

 

AvgUnit =
AVERAGEX (
SUMMARIZE('Table1', 'Table1'[Partner], 'Table1'[Date]),
CALCULATE(sum('Table1'[Unit]))
)

@Anonymous , appreciate if you can mark the solution. So others can take advantage.

 

Appreciate your Kudos.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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