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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Broly
Frequent Visitor

compare values in different rows

I have a table that contains sales informations. each sales id contains a product with quantities. the data is historized thanks to a column containing the dates (note that this column in an integer and not date column).

Broly_0-1667766934076.png

What I want is a table that will show the difference between today and yesterday. Like this : 

Broly_1-1667767217303.png

The date is from a live connection. How can I do this using DAX ?

 

thanks

1 ACCEPTED SOLUTION
mangaus1111
Solution Sage
Solution Sage

Hi @Broly ,

you can try this measure

Measure = 
VAR _CurrentProduct = SELECTEDVALUE('Facts35'[Product ID])
VAR _CurrentDate = SELECTEDVALUE('Facts35'[Date as integer])
VAR _PreviousRow = 
CALCULATE(
          SUM('Facts35'[Quantity]),
          FILTER(
                 ALL('Facts35'),
                 'Facts35'[Product ID] = _CurrentProduct && 'Facts35'[Date as integer] = _CurrentDate - 1
               )    
        )
RETURN
SELECTEDVALUE('Facts35'[Quantity]) - _PreviousRow

mangaus1111_0-1667772289749.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
mangaus1111
Solution Sage
Solution Sage

Hi @Broly ,

you can try this measure

Measure = 
VAR _CurrentProduct = SELECTEDVALUE('Facts35'[Product ID])
VAR _CurrentDate = SELECTEDVALUE('Facts35'[Date as integer])
VAR _PreviousRow = 
CALCULATE(
          SUM('Facts35'[Quantity]),
          FILTER(
                 ALL('Facts35'),
                 'Facts35'[Product ID] = _CurrentProduct && 'Facts35'[Date as integer] = _CurrentDate - 1
               )    
        )
RETURN
SELECTEDVALUE('Facts35'[Quantity]) - _PreviousRow

mangaus1111_0-1667772289749.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.