Forum Discussion
Difference between two rows
- 8 years ago
Hi SSS
Using DAX you can add this calculated column to get desired results
= VAR NextIndex = Table1[Index] + 1 RETURN Table1[Orders] - CALCULATE ( VALUES ( Table1[Orders] ), FILTER ( ALL ( Table1 ), Table1[Index] = NextIndex ) )
Hello Guys,
I have the same question on how to find the difference between two rows from the dated column. Below is how my table looks.
| Date | Quantity | Diff |
| 06/01/2020 | 1 | |
| 06/02/2020 | 3 | 2 |
| 06/03/2020 | 6 | 3 |
I just want the difference between the quantity column. I have tried multiple queries but it works fine in Import Mode but mine is Direct Query mode. Looks like there are many limitations in Direct Query. Could someone help me in giving some guidance regarding this for DIrect Query?
Thanks in advance.
- Ashish_Mathur5 years agoSuper User
Hi,
You should have a Calendar Table with a relationship from the Date column of your Data Table to the Date column of your Calendar Table. To your visual, drag the Date column from the Calendar Table. Write these measures:
Quantity = sum(Data[Number])
Quantity on previous day = calculate([quantity],previousday(calendar[date]))
Diff in quantity = [quantity]-[Quantity on previous day]
Hope this helps.
- Rathan5 years agoFrequent Visitor
Thank you. It worked
- Ashish_Mathur5 years agoSuper User
You are welcome. If my reply helped, please mark it as Answer.