cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Delta Values from Previous Day Using Multiple Columns

Hello,

 

I have searched delta values for previous days but found an answer yet.

 

I am looking to produce dynamic delta values for specific items in tanks. The desired column is in blue below (outlined in green):

 

DeltaVolumesPowerBIexample.jpg

 

The delta value reflects the difference between the current value and the previous day’s for the product in the specific tank.  For example, ‘PeanutButter’ in ‘TK1’ increases by 200 from 100 to 300 (300-100 = 200). The ‘Delta from Previous Day’ column needs only to reflect the previous day’s value.

 

The ‘Data Connectivity Mode’ is ‘Import’ on connected databases.

 

Thank you for your help,

 

Chris  

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Memorable Member
Memorable Member

Re: Delta Values from Previous Day Using Multiple Columns

So... I can't see why there would be a ciruclar dependency error, but my expression isn't QUITE correct either, please update, and maybe do a "plz work, plz work, plz work" dance 🙂

VOLUME_DELTA =

VAR Yesterday = MyTable[StartTime] - 1

VAR MyMaterial = MyTable[Material Number]

VAR MyElement = MyTable[Element]

RETURN
    MyTable[Volume] -

    CALCULATE(VALUES(MyTable[Volume]),
            FILTER(ALL(MyTable),
                        MyTable[StartTime] = Yesterday &&

                        MyTable[Material Number] = MyMaterial &&

                        MyTable[Element] = MyElement
            )

     )

View solution in original post

7 REPLIES 7
Highlighted
Memorable Member
Memorable Member

Re: Delta Values from Previous Day Using Multiple Columns

Well, this makes sense to me... try it 🙂

 

VAR Yesterday = MyTable[StartTime] - 1

VAR MyMaterial = MyTable[Material Number]

VAR MyElement = MyTable[Element]

RETURN
    VALUES(MyTable[Volume]) -

    CALCULATE(VALUES(MyTable[Volume]),
            FILTER(MyTable,
                        MyTable[StartTime] = Yesterday &&

                        MyTable[Material Number] = MyMaterial &&

                        MyTable[Element] = MyElement
            )

     )

 

Highlighted
Regular Visitor

Re: Delta Values from Previous Day Using Multiple Columns

There was a circular dependency error when I put 'VOLUME_DELTA = ' at the beginning of the formula you sent to me. Please let me know if there is a step that I am missing or something else that I need to do with my data to rememdy this challenge:

 

 

VOLUME_DELTA =

VAR Yesterday = MyTable[StartTime] - 1

VAR MyMaterial = MyTable[Material Number]

VAR MyElement = MyTable[Element]

RETURN
    VALUES(MyTable[Volume]) -

    CALCULATE(VALUES(MyTable[Volume]),
            FILTER(MyTable,
                        MyTable[StartTime] = Yesterday &&

                        MyTable[Material Number] = MyMaterial &&

                        MyTable[Element] = MyElement
            )

     )

 

Thank you,

 

Chris

Highlighted
Memorable Member
Memorable Member

Re: Delta Values from Previous Day Using Multiple Columns

Man, I am just CURSED by circular references lately.   Do you have OTHER calculated columns in the table?  Do you need them? 🙂

 

Read here about the interaction between multiple calc columns:

https://www.sqlbi.com/articles/understanding-circular-dependencies/

 

Highlighted
Regular Visitor

Re: Delta Values from Previous Day Using Multiple Columns

The other calculated columns that were added have now been removed and the circular dependency is still registering as the error.

 

I appreciate your help.

 

Chris

Highlighted
Memorable Member
Memorable Member

Re: Delta Values from Previous Day Using Multiple Columns

So... I can't see why there would be a ciruclar dependency error, but my expression isn't QUITE correct either, please update, and maybe do a "plz work, plz work, plz work" dance 🙂

VOLUME_DELTA =

VAR Yesterday = MyTable[StartTime] - 1

VAR MyMaterial = MyTable[Material Number]

VAR MyElement = MyTable[Element]

RETURN
    MyTable[Volume] -

    CALCULATE(VALUES(MyTable[Volume]),
            FILTER(ALL(MyTable),
                        MyTable[StartTime] = Yesterday &&

                        MyTable[Material Number] = MyMaterial &&

                        MyTable[Element] = MyElement
            )

     )

View solution in original post

Highlighted
Frequent Visitor

Re: Delta Values from Previous Day Using Multiple Columns

Try this measure:

 

Delta Measure = SUM(MyTable[Volume]) - CALCULATE(SUM(MyTable[Volume]),DATEADD(MyTable[StartTime],-1,DAY))

 

Then just create a Table or Matriz Visualization and done!

Highlighted
Regular Visitor

Re: Delta Values from Previous Day Using Multiple Columns

This newer version worked.

 

My dance came after.

 

Thanks for the help.

 

Chris

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Power BI Desktop August 2020 Update

Power BI Desktop August 2020 Update

We have great updates this month! Click the link for the video with more info.

Top Solution Authors
Top Kudoed Authors