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
lbuzz
Frequent Visitor

Calculate a table of Min, Max, and Average across multiple columns

My table contains 4 columns and I am aiming to create a table such that I can show the min, max, avg, and weighted avg of 3 columns(4th column has values that help calculated the weighted average formula.

The rows should say Min, Max, Avg etc and columns should say the Column names. It's like a pivot table in Excel but I'm not able to replicate it in powerBI.
 The end result looks like this table from excel I have attached. Appreciate any guidance on this
Capture.PNG

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @lbuzz 

 

you can create a new query where you are using Table.Profile to create a new table with the desired data. Here an example code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYlOlWJ1oIKmjZAHEJmCeMZAFwbGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", Int64.Type}, {"C", Int64.Type}}),
    TableProfile= Table.Profile(#"Changed Type")
in
    TableProfile

The output of this function you can easily show in a table-visual

Jimmy801_0-1601535815936.png

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

3 REPLIES 3
Jimmy801
Community Champion
Community Champion

Hello @lbuzz 

 

you can create a new query where you are using Table.Profile to create a new table with the desired data. Here an example code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYlOlWJ1oIKmjZAHEJmCeMZAFwbGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", Int64.Type}, {"C", Int64.Type}}),
    TableProfile= Table.Profile(#"Changed Type")
in
    TableProfile

The output of this function you can easily show in a table-visual

Jimmy801_0-1601535815936.png

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Fowmy
Super User
Super User

@lbuzz 

To have the format you desire, you need to use a MATRIX visual and go to Value Property and set the show on Row to ON

 

Fowmy_0-1601493774020.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

lbuzz
Frequent Visitor

Hello thank you so much for the early reply
But if I use a matrix and drop the values with Row selection, I end up seeing a top to bottom structure vs a pivot matrix style. If somehow I could Fix the keywords Min Max,Avg on rows and every new column A,B,C goes into new column, that'd really help me 
Capture.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.

Top Solution Authors