cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DarylRob
Helper I
Helper I

DAX : Pivot a table to get totals

So I've got the below table imported. 

 

NameRegionProject NameTotal MRRTotal Hours
AndyUS 1005
TrevorUK 20010
AndyUS 30015
TrevorUK 400

20

SandyUS 500

25

 

I then want to be able to create a calculated table that will come out as below

 

RegionNameTotal MRRTotal Hours
USAndy40020
UKTrevor60030
USSandy50025

 

So I basically just want ot pivot up the totals of each person. 

 

I'm new to Power BI so don't know where to start

 

Thanks, 

1 ACCEPTED SOLUTION
bcdobbs
Super User
Super User

If you did specifically want a calculated table you could do this:

bcdobbs_2-1640199289719.png

SummaryTable = 
SUMMARIZECOLUMNS(
    MainTable[Region],
    MainTable[Name],
    "Total Hours", CALCULATE ( SUM ( MainTable[Total Hours] ) ),
    "Total MRR", CALCULATE ( SUM ( MainTable[Total MRR] ) )
)


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

It looks like you want a visual and not a calculated table.  If that is the case, do this.  To your Table/matrix visual, drag Region and Name.  Write these measures:

MRR total = sum(Data[Total MRR])

Hours = sum(Data[Total hours])

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks Asish, but I then want to be able to put this into a line chart to show progression over time, which wouldnt work with this would it?

Hi,

For that you must have a Date column in your dataset as well.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
bcdobbs
Super User
Super User

If you did specifically want a calculated table you could do this:

bcdobbs_2-1640199289719.png

SummaryTable = 
SUMMARIZECOLUMNS(
    MainTable[Region],
    MainTable[Name],
    "Total Hours", CALCULATE ( SUM ( MainTable[Total Hours] ) ),
    "Total MRR", CALCULATE ( SUM ( MainTable[Total MRR] ) )
)


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Now i've got another table that's got Q1, Q2, Q3, Q4 row data in how would I bring that into this? Call it table2 and its as below

 

NameQuarterMRR QuotaHours Quota
AndyQ1100050
AndyQ2200050
AndyQ3300050
AndyQ4400050

This is perfect, thank you

bcdobbs
Super User
Super User

Hi,
Do you specifically need a calculated table or just want a visual to display a table like that?

If the later just drop the columns into a table visual like this:

bcdobbs_0-1640198972502.png

 

Power Bi by will guess what agregation you want for a numeric column but you can check it by clicking the down arrow on a field after you drop it into a viusal:

bcdobbs_1-1640199118753.png

 

Can send the DAX over if you specifically want a calculated table.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Hi, 

I forgot to include the date columns that i'll also have (Q1, Q2, Q3, Q4) which I then want to be able to show in a line chart. Which I don't think I can do via this method?

Can you mock up a demo pbix file and send it. Think even bringing dates in you can keep it simple maybe with the addition of a date table. Might be missing something though.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.