cancel
Showing results for
Did you mean:
Helper II

## Calculate Difference between change in value

Hi,

In general, we calculate the Cummulative Total of the values, but my requirement is to get the each day change in value based on Cummulative values. See the attachement.

Left side table is my Main dataset and right side one are the expected result.

How to calculate the change in values based on Running Total, as see the GREEN Color field.

Also, this could be a running total for all Category as well.

Thanks

Shishir

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III

## Re: Calculate Difference between change in value

@shishir999

Try this pattern

```Calc col =
[Value]
- MINX (
TOPN (
1,
FILTER ( Table1, [Ctg] = EARLIER ( [Ctg] ) && [Date] < EARLIER ( [Date] ) ),
[Date], DESC
),
[Value]
)
```
Try my new Power BI game Cross the River
5 REPLIES 5
Super User III

## Re: Calculate Difference between change in value

@shishir999

Try this pattern

```Calc col =
[Value]
- MINX (
TOPN (
1,
FILTER ( Table1, [Ctg] = EARLIER ( [Ctg] ) && [Date] < EARLIER ( [Date] ) ),
[Date], DESC
),
[Value]
)
```
Try my new Power BI game Cross the River
Helper II

## Re: Calculate Difference between change in value

Thanks Zubair for the solution.

I was trying this earlier:

***********************

Var Mx = CALCULATE(MAXX(table, [Value]),
FILTER(table,
[Date] <= EARLIER([Date])
))
Var Mi = CALCULATE(MAXX(Table,[value]),
FILTER(table,
[Date] = MIN([Date])
))
Var diff = Mx- Mi
Return
diff

***************************

Thanks

Shishir

Super User III

## Re: Calculate Difference between change in value

@shishir999

This is how it works for each row to get the previous Cumulative Value

1) First Filter gets a filtered table with all dates less than current row date

2) TOPN on this Filtered Table gets the lastrow from the Filtered Table

3) MINX is used to get the Value on this Date

so basically the flow is MINX<<<TOPN<<<<Filter

Try my new Power BI game Cross the River
Helper II

## Re: Calculate Difference between change in value

Thanks alot for explaination.

Regards

Shishir Goel

Helper II

## Re: Calculate Difference between change in value

Hi Zubair,

I need one more help here.

In the same query, how can I restrict that my 1st min. value must remain ZERO and after that, if any changes in the value, it will calculate it, as the exisiting query working.

Thanks

Shishir G.

Announcements

#### 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!

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

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.

#### Community Summit North America

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

Top Solution Authors
Top Kudoed Authors