Forum Discussion
Nepal101
2 years agoHelper III
Calculating days between dates in same column
Hello Everyone, I have a question regarding how to calculate the column or Measure that gives me days between dates Date ClientName salesperson Days Between Running total days or sum days ...
danextian
2 years agoSuper User
Hi Nepal101
Use this instead:
Days Diff =
VAR __PREV =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER (
'Table',
'Table'[Date] < EARLIER ( 'Table'[Date] )
&& 'Table'[ClientName] = EARLIER ( 'Table'[ClientName] )
&& 'Table'[salesperson] <> "null" )
)
RETURN
DATEDIFF ( __PREV, 'Table'[Date], DAY ) + 0
As to the running total, you can either use a calc column or a measure but calc column is not to be aggregated as it will show incorrect sub or grand total. Please see attached pbix for the details.
Nepal101
2 years agoHelper III
At first I created
test = If('MV[Salesperson]<>Blank(),'MV'[Date],Blank())
MeasureMIN-new = CALCULATE(MIN('MV'[test]),ALLEXCEPT('MV'[Client Name]))
Measure 3 = [MeasureMIN-new]-1 ( so that I can get 1 day when the salesperson is assigned)
Date diff =
var fistdate= [MeasureMIN-new]
var Demote =
CALCULATE(
MAX('MV'[test]),
Filter(
ALLEXCEPT('MV'[Client Name]),
'MV'[test])))
Return
If (
'MV'[test]=fistdate,
DATEDIFF([Measure 3],'MV'[test],Day),
DATEdiff(Demote,'MV'[test],DAY))
Is there a way to count the days rolling over meaning for 11/6/2023 =1 on 11/7/2023 it should show 2 and 11/8/2023 it should show 3 and for 11/14/2023 it should show 9 for that row of date. is that possible. I can't upload the file so hope this helps what I have explained.
- danextian2 years agoSuper User
Hi Nepal101
I would suggest you provided enough information and sample data that covers your use case instead of just bits and pieces.
- Nepal1012 years agoHelper III
Sorry about the confusion,
I have used what you have provided to me to some extent to get the result. I appreciate your time.
Thank you