Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Finding the value difference between dates

Hi all,

 

I have a table as shown below.

KanyarGG_0-1675068922571.png

 

All I want to do is, create a column which shows the difference of the parameters relative to the previous day for all units. Been browsing all over but didn't manage to find a solution. Thank you for your time

1 ACCEPTED SOLUTION
FreemanZ
Community Champion
Community Champion

maybe Johnt75 forgot to -1 for CurrentDate. like:

Diff to prev day =

VAR CurrentDate = 'Table'[Date]

VAR CurrentUnit = 'Table'[Unit]

VAR CurrentValue = 'Table'[Parameter]

VAR PrevValue =

    LOOKUPVALUE (

        'Table'[Parameter],

        'Table'[Date], CurrentDate-1,

        'Table'[Unit], CurrentUnit,

        0

    )

RETURN

    CurrentValue - PrevValue

View solution in original post

7 REPLIES 7
johnt75
Super User
Super User

You could add a column like

Diff to prev day =
VAR CurrentDate = 'Table'[Date]
VAR CurrentUnit = 'Table'[Unit]
VAR CurrentValue = 'Table'[Parameter]
VAR PrevValue =
    LOOKUPVALUE (
        'Table'[Parameter],
        'Table'[Date], CurrentDate,
        'Table'[Unit], CurrentUnit,
        0
    )
RETURN
    CurrentValue - PrevValue
FreemanZ
Community Champion
Community Champion

maybe Johnt75 forgot to -1 for CurrentDate. like:

Diff to prev day =

VAR CurrentDate = 'Table'[Date]

VAR CurrentUnit = 'Table'[Unit]

VAR CurrentValue = 'Table'[Parameter]

VAR PrevValue =

    LOOKUPVALUE (

        'Table'[Parameter],

        'Table'[Date], CurrentDate-1,

        'Table'[Unit], CurrentUnit,

        0

    )

RETURN

    CurrentValue - PrevValue

Anonymous
Not applicable

@FreemanZ  @johnt75 Yes that worked, thank you both

hi @Anonymous 

something like this shall also work, right?

Diff to prev day =
VAR CurrentDate = 'Table'[Date]
VAR CurrentUnit = 'Table'[Unit]
VAR CurrentValue = 'Table'[Parameter]
VAR PrevValue =
MINX (
     FILTER(
         'Table',
         'Table'[Unit]=CurrentUnit
             &&'Table'[Date]=CurrentDate-1
    ),
    'Table'[Parameter]
RETURN
    CurrentValue - PrevValue
Anonymous
Not applicable

Since I am new to Power BI I can't tell if this should work or not, but when I tried it for my model it didn't 😞

Anonymous
Not applicable

Thank you for your answer but it doesn't work since the assigned value for the PrevValue is same as the Current Value. Hence, the returning value is always 0. I think we should change the date in the lookupvale part to previousday, but I do not know how.

 

Anonymous
Not applicable

@johnt75 I created another column using NEXTDAY and assigned the date in lookupvalue to the created NEXTDAY. That way I fixed it. Thank you

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.