Search code examples
excelpivot-tablepowerpivot

Excel Pivot Data model measures sum


Hello I have in Excel 365 the following data model (Access bindet in the excel data model).

Date Customer Currency ...
2023/02/01 Customer1 10,53
2023/02/05 Customer3 -125,38
2023/03/11 Customer2 -501,23
2023/01/25 Customer1 1,25
2023/01/10 Customer2 354,21
... ...

There are more columns but I think so discuss my problem it's enough.

Now I want a pivot table and a pivot diagram with the following structure.

Month Incoming payment Outgoing payment Balance
Jan 355,46 0 355,46
Feb 10,53 125,38 -114,85
Mar 0 501,23 -501,23

As you see I want the outgoing positiv too! And important because of the data model I cant use calculated field or element in the pivot table directly.

I will filter the pivot with slice, f.e. year, customer,...

I tried too use measures f.e. sum but it doen't fit. I know I can show a result column for the pivot table but this doesn't help for the diagram.

I found this questions but it doesn't help me: https://stackoverflow.com/questions/73394124/custom-column-in-a-pivot-table-from-the-data-model-in-excel


Solution

  • Just create 3 simple measures:

    Balance :=
    0 + SUM( Table1[Currency] )
    
    Incoming Payment :=
    CALCULATE(
        [Balance],
        Table1[Currency] >= 0
    )
    
    Outgoing Payment :=
    - CALCULATE(
        [Balance],
        Table1[Currency] < 0
    )