Forum Discussion
CaveOfWonders
3 years agoHelper IV
SQL Lag to DAX measure
Hi All,
Could someone please help me recreate the below SQL into a DAX measure.
The SQL is returning the previous Actual Date from the previous ReportingDate Partitioned by the ProjectID and ProjectMilestoneID.
SELECT
P.ProjectID,
P.Actual,
P.ReportingDate,
P.ProjectMilestoneID,
LAG(P.Actual) OVER (
PARTITION BY P.ProjectID, P.ProjectMilestoneID
ORDER BY P.ReportingDate
) AS PreviousActual
FROM Project AS P
Here is the Output in SQL. I've highlighted one example at the bottom where project ID = 181 and Project Milestone ID = 3 it pulls back the previous actual date based on the previous reporting date
Sample Table:
ProjectID ActualDate ReportingDate Project Milestone ID
|
1 Reply
- Tahreem24Super User
CaveOfWonders Try to use OFFSET and INDEX dax.