Forum Discussion
Broly
3 years agoFrequent 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).
What I want is a table that will show the difference between today and yesterday. Like this :
The date is from a live connection. How can I do this using DAX ?
thanks
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]) - _PreviousRowIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- mangaus1111Solution 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]) - _PreviousRowIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.