The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Database sample:
I need a DAX Measure (since I'll work with FILTERED VALUES) to calculate the difference between consecutive dates by Squad.
Thank you in advance (=
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
Expected result days: =
VAR _current =
MAX ( Data[DateTime] )
VAR _previous =
CALCULATE (
MAX ( Data[DateTime] ),
OFFSET (
-1,
ALL ( Data[Squad], Data[DateTime] ),
ORDERBY ( Data[DateTime], ASC ),
KEEP,
PARTITIONBY ( Data[Squad] )
)
)
RETURN
IF (
HASONEVALUE ( Data[Squad] ),
DATEDIFF ( _previous, _current, MINUTE ) / ( 24 * 60 )
)
Hi,
Please check the below picture and the attached pbix file.
Expected result days: =
VAR _current =
MAX ( Data[DateTime] )
VAR _previous =
CALCULATE (
MAX ( Data[DateTime] ),
OFFSET (
-1,
ALL ( Data[Squad], Data[DateTime] ),
ORDERBY ( Data[DateTime], ASC ),
KEEP,
PARTITIONBY ( Data[Squad] )
)
)
RETURN
IF (
HASONEVALUE ( Data[Squad] ),
DATEDIFF ( _previous, _current, MINUTE ) / ( 24 * 60 )
)
User | Count |
---|---|
10 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
21 | |
14 | |
14 | |
9 | |
7 |