Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
TBSST
Frequent Visitor

Finding overdue surveys by using previous date in column

Hi All, 

 

This may seem like a repeat of a question i had before, however I think what i supplied did not reflect what i was trying to achive. I am trying to find surveys that were not completed within 3 months. I am dertmining this by using the date completed column. i am using the date, and determining if the previous complete date from the same ID is within 3 months.  

IDSurveyIDDate Compelted
a770920/05/2022
a806618/10/2022
a857821/02/2023
a103235/07/2023
b864422/02/2023
b1024727/06/2023
c87901/03/2023
c101929/06/2023
d85317/02/2023
d89618/05/2023
d105958/08/2023

 

I am wanting to be able to add another column showing how many months were in between each survey. The first date being marked as "first" as there is no date to go off prior to the first one. An example of what i want is: 

 

IDSurveyIDDate CompeltedMonths since last due
a770920/05/2022First
a806618/10/20224
a857821/02/20234
a103235/07/20235
b864422/02/2023First
b1024727/06/20234
c87901/03/2023First
c101929/06/20234
d85317/02/2023First
d89618/05/20233
d105958/08/20233


The second part is i would like a card to identify how many overdue surveys there were. So for the sample above, there would be 4 overdue surveys. 

thank you for your support. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @TBSST ,

 

Based on your description, I created the sample with dd/mm/yyyy and got the following results:

vtianyichmsft_0-1697689733559.png


I calculated it with 30 days as a month, and some of the results I got were a bit inconsistent with what you expected, so please correct me if I misunderstood your need!

DAX for column:

Previous =
var CurrentSurveyID = Survey[SurveyID]
var _pre = CALCULATE(
MAX(Survey[Date Compelted]),
FILTER(Survey, Survey[SurveyID] < CurrentSurveyID && Survey[ID] = EARLIER(Survey[ID]))
)
return
ROUND(DATEDIFF(_pre,'Survey'[Date Compelted],DAY)/30,0)

 

An attachment for your reference. Hope it helps!

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @TBSST ,

 

Based on your description, I created the sample with dd/mm/yyyy and got the following results:

vtianyichmsft_0-1697689733559.png


I calculated it with 30 days as a month, and some of the results I got were a bit inconsistent with what you expected, so please correct me if I misunderstood your need!

DAX for column:

Previous =
var CurrentSurveyID = Survey[SurveyID]
var _pre = CALCULATE(
MAX(Survey[Date Compelted]),
FILTER(Survey, Survey[SurveyID] < CurrentSurveyID && Survey[ID] = EARLIER(Survey[ID]))
)
return
ROUND(DATEDIFF(_pre,'Survey'[Date Compelted],DAY)/30,0)

 

An attachment for your reference. Hope it helps!

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

DallasBaba
Skilled Sharer
Skilled Sharer

@TBSST you can create a calculated column to find the previous completion date:

 

Previous Completion Date =
VAR CurrentSurveyID = Survey[SurveyID]
RETURN
CALCULATE(
MAX(Survey[Date Completed]),
FILTER(Survey, Survey[SurveyID] < CurrentSurveyID && Survey[ID] = EARLIER(Survey[ID]))
)

--- Create another calculated column to find the months since the last due date:

Months Since Last Due =
VAR PrevCompletionDate = [Previous Completion Date]
VAR CurrentDate = Survey[Date Completed]
RETURN
IF(
ISBLANK(PrevCompletionDate),
"First",
IF(
DATEDIFF(PrevCompletionDate, CurrentDate, MONTH) > 3,
"Overdue",
DATEDIFF(PrevCompletionDate, CurrentDate, MONTH)
)
)

 

--- create a measure to count the overdue surveys:

Overdue Surveys =
CALCULATE(
COUNTROWS(Survey),
FILTER(Survey, [Months Since Last Due] = "Overdue")
)

Now, you can use two calculated columns and measure in your  visuals:

 

Drag the "ID" and "SurveyID" columns into a table or matrix visual.
Use the "Date Completed" column for the date axis if needed.
Drag the "Months Since Last Due" calculated column to a visual to see how many months have passed since the last survey.
Use the "Overdue Surveys" measure in a card visual to display the count of overdue surveys.

Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Let me know if this work
@ me in replies or I'll lose your thread!!!

Thanks
Dallas

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.