Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Database sample:
ID | Data de início real | Squad |
ID001 | 03/01/2022 00:00:00 | Squad1 |
ID004 | 04/01/2022 00:00:00 | Squad1 |
ID007 | 06/01/2022 12:00:00 | Squad1 |
ID002 | 03/01/2022 14:00:00 | Squad2 |
ID008 | 07/01/2022 23:00:00 | Squad2 |
ID009 | 07/01/2022 23:00:00 | Squad2 |
ID010 | 08/01/2022 03:21:06 | Squad2 |
ID011 | 09/01/2022 05:00:00 | Squad2 |
ID003 | 03/01/2022 22:30:00 | Squad3 |
ID005 | 05/01/2022 23:00:00 | Squad3 |
ID006 | 05/01/2022 23:00:00 | Squad3 |
The DAX Measure must return the interval of the dates grouped by "Squad".
Must return zero on first Squad row & when there's no interval between two dates.
ID | Data de início real | Squad | Interval (Days) |
ID001 | 03/01/2022 00:00:00 | Squad1 | 0,00 |
ID004 | 04/01/2022 00:00:00 | Squad1 | 1,00 |
ID007 | 06/01/2022 12:00:00 | Squad1 | 2,50 |
ID002 | 03/01/2022 14:00:00 | Squad2 | 0,00 |
ID008 | 07/01/2022 23:00:00 | Squad2 | 4,38 |
ID009 | 07/01/2022 23:00:00 | Squad2 | 0,00 |
ID010 | 08/01/2022 03:21:06 | Squad2 | 0,18 |
ID011 | 09/01/2022 05:00:00 | Squad2 | 1,07 |
ID003 | 03/01/2022 22:30:00 | Squad3 | 0,00 |
ID005 | 05/01/2022 23:00:00 | Squad3 | 2,02 |
ID006 | 05/01/2022 23:00:00 | Squad3 | 0,00 |
I appreciate so much you help.
Solved! Go to Solution.
Interval(Days) =
VAR _pre =
CALCULATE (
MAX ( 'TestTable'[Data de início real] ),
OFFSET (
-1,
ALLSELECTED (
'TestTable'[Data de início real],
TestTable[Squad],
TestTable[ID]
),
ORDERBY ( 'TestTable'[Data de início real] ),
,
PARTITIONBY ( 'TestTable'[Squad] )
)
)
RETURN
IF ( _pre, VALUE ( MAX ( 'TestTable'[Data de início real] ) - _pre ), 0 )
Interval(Days) =
VAR _pre =
CALCULATE (
MAX ( 'TestTable'[Data de início real] ),
OFFSET (
-1,
ALLSELECTED (
'TestTable'[Data de início real],
TestTable[Squad],
TestTable[ID]
),
ORDERBY ( 'TestTable'[Data de início real] ),
,
PARTITIONBY ( 'TestTable'[Squad] )
)
)
RETURN
IF ( _pre, VALUE ( MAX ( 'TestTable'[Data de início real] ) - _pre ), 0 )