cancel
Showing results for
Did you mean:
Highlighted
Member

## Doesn't work comulative total

Hey guys,

I'm desperate, I don't know is something wrong with data, formula, or just me.

I have to tables Calendar (dates) and Item Ledger entry (item turnover data), they are related by Calendar[Date] - Item Ledger Entry [Posting Date].

The result should be table wich shows some other measures (sales data) regarding date filter and a colum in the end [ Stock]. Stock shows how much items we have left to last date of filter (it ignores first filter date). First of all I must calculate commulative total, and just stuck here.

Formula that I use:

```Stock (1) = CALCULATE(
SUM('Item ledger entry'[Quantity]),
FILTER(ALL(Calendar),
Calendar[Date]<=MAX(Calendar[Date])))```

It doesnt worg it gives same amount as [Quantity].

Also I tried this:

```Stock (2) = CALCULATE(
SUM('Item ledger entry'[Quantity]), FILTER( ALLSELECTED(Calendar[Date]), ISONORAFTER(Calendar[Date], MAX(Calendar[Date]), DESC)))```

It didint work eigher.

What I get:

Maybe you have any ideas what i'm doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: Doesn't work comulative total

HI @rimgri,

You can try to use below measure formula if it works on your side:

```Stock (1) =
CALCULATE (
SUM ( 'Item ledger entry'[Quantity] ),
FILTER (
ALLSELECTED ( 'Item ledger entry' ),
'Item ledger entry'[Date] <= MAX ( Calendar[Date] )
)
)
```

If above not help, please share some sample data for test and coding formula.

Regards,

Xiaoxin Sheng

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

For learning resources/Release notes, please visit: | |
3 REPLIES 3
Community Support Team

## Re: Doesn't work comulative total

HI @rimgri,

You can try to use below measure formula if it works on your side:

```Stock (1) =
CALCULATE (
SUM ( 'Item ledger entry'[Quantity] ),
FILTER (
ALLSELECTED ( 'Item ledger entry' ),
'Item ledger entry'[Date] <= MAX ( Calendar[Date] )
)
)
```

If above not help, please share some sample data for test and coding formula.

Regards,

Xiaoxin Sheng

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

For learning resources/Release notes, please visit: | |
Member

## Re: Doesn't work comulative total

Thanks, @v-shex-msft, it works!

Could you bit explain why ALLSELECTED must be 'Item ledger entry' if my Data field is in 'Calendar' table?

Community Support Team

## Re: Doesn't work comulative total

Hi @rimgri,

Cumulative total calculation need to across multiple row which mean calculation need to ignore 'per row contents filter' effect, that is why I add it to 'Item ledger entry' table.

When you add all/allselected on calendar table, it only means you will get a max date from whole or filtered calendar table.

It will choose related records from 'Item ledger entry' table with condition 'Item ledger entry date value less than max calendar date'.

Cumulative Total

Regards,

Xiaoxin Sheng

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

For learning resources/Release notes, please visit: | |

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 39 members 1,608 guests
Recent signins: