cancel
Showing results for
Did you mean:
Ronald_01 Regular Visitor

## Budget Minus Margin Calculation

Hi All,

I'am encountering some problems in calculating budget minus maring (per week and per account).

I calculating over 3 tables:

Account for the account name, Budget for the budget and margin from a margin table.

I'am using this calculation:

```Verschil = CALCULATE(
SUM(Easyflex_data[Marge])
-
SUM(Begroting[Budget]);
FILTER(ALL('Date'); 'Date'[week] <= 'Date'[week]);
FILTER(ALLSELECTED(Account); Account[Account name] = Account[Account name]))```

But I get this answer: (where marge stands for margin and verschil for difference) I also tried this calculation:

```Verschil = CALCULATE(
SUM(Easyflex_data[Marge])
-
SUM(Begroting[Budget]))```

But with this incorrect result, I figured out that the calculation adds twice the budget. Does anyone know what I'm doing wrong and what is a possible solution to this problem?

Ronald

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted v-sihou-msft
Moderator

## Re: Budget Minus Margin Calculation

@Ronald_01

In this scenario, both Easyflex_data and Begroting table suppose to have foreign key columns connecting Date and Account dimension table. If you want to calculate the different group on week and account, you can use ALLEXCEPT() in your calculation to group on [week] and [Budhet].

```Verschil =
CALCULATE (
SUM ( Easyflex_data[Marge] ),
ALLEXCEPT (
Easyflex_data,
RELATED ( 'Date'[week] ),
RELATED ( Account[Account name] )
)
)
- CALCULATE (
SUM ( Begroting[Budget] ),
ALLEXCEPT (
Begroting,
RELATED ( 'Date'[week] ),
RELATED ( Account[Account name] )
)
)```

If you still get incorrect result, please share some sample data in your source table. I still can't understand the currency format in your screenshots.

Regards,

Highlighted v-sihou-msft
Moderator

## Re: Budget Minus Margin Calculation

@Ronald_01

In this scenario, both Easyflex_data and Begroting table suppose to have foreign key columns connecting Date and Account dimension table. If you want to calculate the different group on week and account, you can use ALLEXCEPT() in your calculation to group on [week] and [Budhet].

```Verschil =
CALCULATE (
SUM ( Easyflex_data[Marge] ),
ALLEXCEPT (
Easyflex_data,
RELATED ( 'Date'[week] ),
RELATED ( Account[Account name] )
)
)
- CALCULATE (
SUM ( Begroting[Budget] ),
ALLEXCEPT (
Begroting,
RELATED ( 'Date'[week] ),
RELATED ( Account[Account name] )
)
)```

If you still get incorrect result, please share some sample data in your source table. I still can't understand the currency format in your screenshots.

Regards,

Announcements #### Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future. Learn the answers to some of the questions asked during the Amanda Triple A event. #### October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.  Top Kudoed Authors
Users Online
Currently online: 6 members 1,781 guests
Recent signins:
• antigravity • SHAMAK • QLD_Jay • Hnd12000 • Tyron • prakash_gautam • Thuy • AlexisBICE • keeratibenz • chris886 • andres_guerrero • YukiPu_1993 • kevinjung 