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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
cfausnaught
Frequent Visitor

Confusion with DAX syntax, difference between rows?

Hi! I'm having some trouble understanding DAX syntax when it comes to differences between rows. I want to accomplish this in its own column for a matrix...

 

if ('Table'[Date].[Year] - 1 == EARLIER('Table'[Date].[Year]) AND 'Table'[Type] == EARLIER('Table'[Type])):

  new_column = 'Table'[TypeCount] - EARLIER('Table'[TypeCount])

else:

  new_column = 0

 

Does that make sense? I'm having some real problems translating this to DAX. My confusion is especially in the EARLIER() expression, and I'm a tad confused which expression I should be using in the first place to get this if statement working. Should I maybe use CALCULATE()? IF()? Just having some trouble with the new syntax.

 

To elaborate further, my goal is to get the difference between two dates based on the count of the type. So for instance if April 2015 "new" types had a count of 2, and April 2016 "new" types had a count of 4, I would have a column with the difference between these two values (2) that shows the change over time.

1 ACCEPTED SOLUTION
cfausnaught
Frequent Visitor

After some headscratching I came up with a solution that seems to be working... here it is for those who have similar problems!

 

Year Delta = IF(LOOKUPVALUE('Signings and Losses'[TypeCount],'Signings and Losses'[DateSum],[LastDateSum],'Signings and Losses'[Type],'Signings and Losses'[Type])>0,
'Signings and Losses'[TypeCount] - LOOKUPVALUE('Signings and Losses'[TypeCount],'Signings and Losses'[DateSum],[LastDateSum],'Signings and Losses'[Type],'Signings and Losses'[Type])

, 0)

View solution in original post

1 REPLY 1
cfausnaught
Frequent Visitor

After some headscratching I came up with a solution that seems to be working... here it is for those who have similar problems!

 

Year Delta = IF(LOOKUPVALUE('Signings and Losses'[TypeCount],'Signings and Losses'[DateSum],[LastDateSum],'Signings and Losses'[Type],'Signings and Losses'[Type])>0,
'Signings and Losses'[TypeCount] - LOOKUPVALUE('Signings and Losses'[TypeCount],'Signings and Losses'[DateSum],[LastDateSum],'Signings and Losses'[Type],'Signings and Losses'[Type])

, 0)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.