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
jhurst
Regular Visitor

How to have both total and average

I'm a Power BI newbie & hope someone can help. I have a table visualization (I've also tried matrix as well) & want to have BOTH a Total AND Average at the bottom (like the picture below).  I've gotten one or the other but not both at the same time.  Is this possible?

powerbi-totalaverage.PNG

1 ACCEPTED SOLUTION

Actually, building on my previous reply, you can put a line break in a measure with a shift + enter inside a text string.

jdbuchanan71_0-1595520283337.png

Then you get something like this which is close

jdbuchanan71_1-1595520327616.png

You do have to turn on Word wrap for the values field as well in order for the line break to show up.

 

View solution in original post

11 REPLIES 11
jdbuchanan71
Super User
Super User

@jhurst 

You could do something like this where you check if you are on a reqular row (a single date) and if not return both the total and the average.

COUNT = 
VAR _avg = AVERAGEX ( VALUES ( 'Date'[Date] ), [Count Measure] )
VAR _count = [Count Measure]
RETURN
    IF (
        HASONEVALUE ( 'Date'[Date] ),
        _count,
        FORMAT ( _count, "#,#" ) & " (" & FORMAT ( _avg, "#,#" & ")" )
    )

jdbuchanan71_1-1595519917916.png

 

Actually, building on my previous reply, you can put a line break in a measure with a shift + enter inside a text string.

jdbuchanan71_0-1595520283337.png

Then you get something like this which is close

jdbuchanan71_1-1595520327616.png

You do have to turn on Word wrap for the values field as well in order for the line break to show up.

 

@ jdbuchanan71

So this code is a measure, right? (I did say I was new to this)

When I enter it, then adjust for the names of my table & fields I get the message "The name 'Count' is already used for a column name on table 'Query1'.  Choose a different name."  Then when I rename it, it ends up adding a new column instead of just putting the total & average on the bottom of the existing column.

powerbi-totalaverage3.PNG

Right, you can take your first column out though and only show the new one.

So if I have multiple columns & wanted the total & average for each of them, I'd need to create multiple measures - one for each of them?

That's correct.  

@ jdbuchanan71

Maybe.  Is there any way to change the row name to "Total (Average)"?  Otherwise people wouldn't necessary know what that 2nd number was.

Yes, you can change the total label in the formatting:

jdbuchanan71_0-1595520559075.png

 

amitchandak
Super User
Super User

@jhurst , I doubt you can have an additional total row. You can have either avg or total.

camargos88
Community Champion
Community Champion

Hi @jhurst ,

 

I haven't seen a visual like this. However you can drag the same column again to the visual and change the aggregation in the fields pane.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Unfortunately, it added a new column with the same data; not exactly what I was looking for.

powerbi-totalaverage2.PNG

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.