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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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