Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I was wondering if there was a way to subtract a previous row value grouped by lets say Name. The screenshot of what I am trying to achieve is below. If there was no previous row for the individual there wouldnt be a value to subtract. I also sorted name and year by ascending order. In power query or Dax it does not matter, I just need that difference column.
(Same Table Copy and pasted)
Name | Year | Difference |
A | 2019 | N/A |
A | 2020 | 1 |
A | 2021 | 1 |
B | 2020 | N/A |
B | 2021 | 1 |
C | 2019 | N/A |
C | 2022 | 3 |
C | 2023 | 1 |
Solved! Go to Solution.
@apvu2 Try:
Difference Column =
VAR __Name = [Name]
VAR __Year = [Year]
VAR __Previous = MAXX(FILTER('Table',[Name] = __Name && [Year] < __Year),[Year])
RETURN
__Year - __Previous
@apvu2 Try:
Difference Column =
VAR __Name = [Name]
VAR __Year = [Year]
VAR __Previous = MAXX(FILTER('Table',[Name] = __Name && [Year] < __Year),[Year])
RETURN
__Year - __Previous
Hi @Greg_Deckler ,
I'm trying to use your formula here, but it seems like the formula can't detect my column name, as it only detect for "measure". May i know why and how do i fix this ?
Hey Greg,
Thank you so much this would definitely work!!!!!!!!!!!!!!!!!
User | Count |
---|---|
97 | |
78 | |
77 | |
48 | |
26 |