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
Anonymous
Not applicable

DAX to show Value changes

Hi, 

 

I am working on window panels and they are going to be inspected for the forseeable future based on their Priority levels. I want to show in a calcualted column or measure, the window panels that have changed priority after each inspection. Either up or down. 

I cannot figure out how to do it. 

 

HELP 😃

 

Panel NoPriorityDate CreatedDate of Inspection
1289P304/11/202004/11/2020
1345P204/11/202005/05/2021
1289P104/11/202006/07/2021
5000P212/10/202001/02/2021
5000P112/10/202012/12/2020
5000P212/10/202012/04/2020
1 ACCEPTED SOLUTION

@Anonymous This worked for me with your data:

Column = 
  VAR __Current = RIGHT([Priority],1) * 1
  VAR __PreviousDate = MAXX(FILTER('Table3','Table3'[Date of Inspection] < EARLIER('Table3'[Date of Inspection]) && [Panel No]=EARLIER('Table3'[Panel No])),[Date of Inspection])
  VAR __Previous = RIGHT(MAXX(FILTER('Table3',[Date of Inspection]=__PreviousDate),[Priority]),1) * 1
RETURN
  IF(ISBLANK(__PreviousDate),0,__Current - __Previous) * -1

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@Anonymous You are going to want something along the lines of MTBF to compare rows:

See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Mean-Time-Between-Failure-MTBF/m-p/625082#M304


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thanks for this, unfortunately it is not producing the solution I am looking for/expecting. 

I will give an example of what I was hoping to see. 

 

Panel NoPriorityDate CreatedDate of InspectionPriority change
1289P304/11/202004/11/20200
1345P204/11/202005/05/20210
1289P104/11/202006/07/20212
5000P212/10/202001/02/2021-1
5000P112/10/202012/12/20201
5000P212/10/202012/04/20200

 

I don't if that makes sense? The formula above is showing me the difference from the previous panel in the the row above...not the difference JUST for that panel. 

@Anonymous This worked for me with your data:

Column = 
  VAR __Current = RIGHT([Priority],1) * 1
  VAR __PreviousDate = MAXX(FILTER('Table3','Table3'[Date of Inspection] < EARLIER('Table3'[Date of Inspection]) && [Panel No]=EARLIER('Table3'[Panel No])),[Date of Inspection])
  VAR __Previous = RIGHT(MAXX(FILTER('Table3',[Date of Inspection]=__PreviousDate),[Priority]),1) * 1
RETURN
  IF(ISBLANK(__PreviousDate),0,__Current - __Previous) * -1

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors