cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cfausnaught Frequent Visitor
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

Accepted Solutions
cfausnaught Frequent Visitor
Frequent Visitor

Re: Confusion with DAX syntax, difference between rows?

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
Frequent Visitor

Re: Confusion with DAX syntax, difference between rows?

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

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)