Forum Discussion
Calculation to find previous date value for every date present in the dataset
- Anonymous6 years ago
Hi,
1. Check the Data Type in Power Query . It should be Date Time.
2. Check whether any values are getting summarised by default in the pane. Make all as Don't Summarize.
3.Change Format of all your Date/Time column to the same one. Choose a format which has DD/MM/YYYY hh:mm:ss AM/PM since your data involves all of theseUse these Measures:
Previous Patient No2 =
VAR a =
MAX ( 'Table6'[Date] )
VAR b =
CALCULATE (
MAX ( Table6[Patient No] ),
FILTER (
ALL (
Table6[Patient No],
Table6[Date],
Table6[Values]
),
Table6[Date] < a
&& Table6[Patient No]
= MAX ( Table6[Patient No] )
)
)
RETURN
b
Previous Date2 =
VAR a =
MAX ( 'Table6'[Date] )
VAR b =
CALCULATE (
MAX ( Table6[Date] ),
FILTER (
ALL (
Table6[Patient No],
Table6[Date],
Table6[Values]
),
Table6[Date] < a
&& Table6[Patient No]
= MAX ( Table6[Patient No] )
)
)
RETURN
bPrevious Value2 =
VAR _previousDate = [Previous Date2]
VAR _patientno = [Previous Patient No2]
RETURN
CALCULATE (
MAX ( Table6[Values] ),
FILTER (
ALL ( Table6 ),
Table6[Date] = _previousDate
&& Table6[Patient No] = _patientno
)
)It is working fine for me with Data Type Date Time.
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!
Hi,
1. Check the Data Type in Power Query . It should be Date Time.
2. Check whether any values are getting summarised by default in the pane. Make all as Don't Summarize.
3.Change Format of all your Date/Time column to the same one. Choose a format which has DD/MM/YYYY hh:mm:ss AM/PM since your data involves all of these
Use these Measures:
Previous Patient No2 =
VAR a =
MAX ( 'Table6'[Date] )
VAR b =
CALCULATE (
MAX ( Table6[Patient No] ),
FILTER (
ALL (
Table6[Patient No],
Table6[Date],
Table6[Values]
),
Table6[Date] < a
&& Table6[Patient No]
= MAX ( Table6[Patient No] )
)
)
RETURN
b
Previous Date2 =
VAR a =
MAX ( 'Table6'[Date] )
VAR b =
CALCULATE (
MAX ( Table6[Date] ),
FILTER (
ALL (
Table6[Patient No],
Table6[Date],
Table6[Values]
),
Table6[Date] < a
&& Table6[Patient No]
= MAX ( Table6[Patient No] )
)
)
RETURN
b
Previous Value2 =
VAR _previousDate = [Previous Date2]
VAR _patientno = [Previous Patient No2]
RETURN
CALCULATE (
MAX ( Table6[Values] ),
FILTER (
ALL ( Table6 ),
Table6[Date] = _previousDate
&& Table6[Patient No] = _patientno
)
)
It is working fine for me with Data Type Date Time.
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!
Thank you so much for all the help and quick response Anonymous . This solution is working!