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.
Hi community,
I am stuck at the following. I want to obtain the time difference in seconds between rows based on a rank and the same column value in DAX.
This is my data:
I want to obtain the time difference in seconds between a rank and it's previous rank, whilst having the same club_id.
The result would look like this:
I tried to do it kinda like this answer, but without success. It would be nice to understand the DAX behind getting data with the same column values.
Thanks in advance for any help, tips or tricks!
Solved! Go to Solution.
@Anonymous Use this:
seconds =
VAR __clubID = [club_id]
VAR __rank = [rank_team]
VAR __previous = MAXX(FILTER('Table',[club_id] = __clubID && [rank_team] < __rank),[joined_at])
RETURN
IF( __previous = BLANK(), 0, ROUND( ( [joined_at] - __previous ) * 1. * 24 * 60 * 60, 0) )
PBIX is attached below signature. For a full explanation: 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
@Anonymous Use this:
seconds =
VAR __clubID = [club_id]
VAR __rank = [rank_team]
VAR __previous = MAXX(FILTER('Table',[club_id] = __clubID && [rank_team] < __rank),[joined_at])
RETURN
IF( __previous = BLANK(), 0, ROUND( ( [joined_at] - __previous ) * 1. * 24 * 60 * 60, 0) )
PBIX is attached below signature. For a full explanation: 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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
89 | |
68 | |
61 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |