cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
patrisack
Frequent Visitor

Change sum in Pivot-table

Hi!

 

I need help in creating a measure to calculate a PnL in a Pivot Table format. I have a account hierarchy structured so that it can easily be displayed as a pivot table, however I want to change the way the top account category summarize the account values. 

 

I want that the top account category summarize all the accounts prior to that sum. So the sum for "Kontokategori 1 ID" 10 (Account Category in Swedish) should be all accounts in Kontokategori 1 ID=10, but the sum for Kontokategori 1 ID 11 should be the sum for all accounts in both kontokategori ID 10 and 11. The sum for account category should be the sum for all accounts in Kontokategori 1 ID 10, 11 or 13 and so on. 

 

I've made a column called "Kontosort" so that all accounts comes in the order they should be summarized - but I've not managed to create a calculation that can show the correct value both for sums and for individual accounts.

 

EDIT: Here is a file with example data

 

These forums have been extremly helpful with my issues before, hope that someone can help me once again.

 

Happy Holidays!

 

/P

 

Example Pivot Table:

Example Pivot.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-piga-msft Resident Rockstar
Resident Rockstar

Re: Change sum in Pivot-table

Hi @patrisack,

 

Sorry for my mistake. Here is the measure I refer to the measure2.

 

Measure = CALCULATE(SUM(Table1[Belopp]),ALLEXCEPT(Table1,Table1[K1 ID],Table1[Date]))

From your image, it seems that you have a date column in Column field in matrix, but I cannot find the date column in your sample data.

 

The attachment is the sample pbix which I tested to reproduce your scenario, please have a reference.





And when you say that the sum can not be shown where the grand total is shown, do you mean the subtotals as well then? (the marked numbers in the attached pictures)?

Yes, we cannot show the measure to the position of subtotals in the matrix.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-piga-msft Resident Rockstar
Resident Rockstar

Re: Change sum in Pivot-table

Hi @patrisack,

 

You could create the measure with the formula below to calculate the accumulate sum based on Kontokategori 1 ID. 

 

Measure 2 =
CALCULATE (
    [Measure],
    FILTER (
        ALLSELECTED ( 'Table1' ),
        'Table1'[K1 ID] <= MAX ( 'Table1'[K1 ID] )
            && 'Table1'[Date] = MAX ( 'Table1'[Date] )
    )
)

Here is the output.

 

Capture.PNG

 

However, if you want to show the accumulate sum in the position which should show grandtotal in the matrix, I'm afraid that we could not do that.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
patrisack
Frequent Visitor

Re: Change sum in Pivot-table

Hi! Thanks for you response! But I don't get the measure to work in my model. What is the measure you refer to in the formula?

And when you say that the sum can not be shown where the grand total is shown, do you mean the subtotals as well then? (the marked numbers in the attached pictures)?

v-piga-msft Resident Rockstar
Resident Rockstar

Re: Change sum in Pivot-table

Hi @patrisack,

 

Sorry for my mistake. Here is the measure I refer to the measure2.

 

Measure = CALCULATE(SUM(Table1[Belopp]),ALLEXCEPT(Table1,Table1[K1 ID],Table1[Date]))

From your image, it seems that you have a date column in Column field in matrix, but I cannot find the date column in your sample data.

 

The attachment is the sample pbix which I tested to reproduce your scenario, please have a reference.





And when you say that the sum can not be shown where the grand total is shown, do you mean the subtotals as well then? (the marked numbers in the attached pictures)?

Yes, we cannot show the measure to the position of subtotals in the matrix.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors