cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
shishir999 Helper II
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. 

 

Ctg_Sample.JPG

 

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

View solution in original post

5 REPLIES 5
Super User III
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

View solution in original post

shishir999 Helper II
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

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

 

Could you please help me to understand the Top 1 use..

 

Thanks

Shishir

Super User III
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
shishir999 Helper II
Helper II

Re: Calculate Difference between change in value

Thanks alot for explaination.

 

Regards

Shishir Goel

shishir999 Helper II
Helper II

Re: Calculate Difference between change in value

Hi Zubair,

 

I need one more help here.

 

Scenario_Prune_Incr.JPG

 

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.

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