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.
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 )
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 |
---|---|
56 | |
27 | |
23 | |
15 | |
11 |
User | Count |
---|---|
76 | |
58 | |
46 | |
17 | |
12 |