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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Rustynom
Frequent Visitor

If statement for greater date

I'm trying to create a "followed up" column in my response table which will return "yes" if a person with a matching user ID in the follow-ups table has a follow-up date greater than the latest response date. If no date exists in the follow-ups table or the date is prior to the latest response, the column should return "no". 

 

Rustynom_1-1671730174743.png

 

Right now I'm doing this with 2 columns; The first returns the latest follow-up reply date from the follow-ups table. The second column returns whether the latest follow-up is greater than the response date. 

 

  1. User's latest follow-up = CALCULATE( MAX('Follow-Ups'[Follow-up reply date].[Date] ), filter( 'Follow-Ups', 'Follow-Ups'[User ID] = 'Responses'[User ID] ) )
  2. Needs Follow-up? = IF('Responses'[User's latest follow-up].[Date]<'Responses'[Latest Response Date].[Date],"Yes","No")

 

I'm new to this and my approach works but seems inneficient.

 

1 ACCEPTED SOLUTION

Hi @Rustynom ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1672035274836.pngvtangjiemsft_1-1672035288746.png

vtangjiemsft_2-1672035321062.png

 

(2) We can create a calculated column.

Needs Follow-up = var _maxdate=MAXX(FILTER('Follow-Ups',[User ID]=Responses[User ID]),[Follow-uo reply date])

 return IF(_maxdate>=[Latest Response Date],"Yes","No")

(3) Then the result is as follows.

vtangjiemsft_3-1672035364802.png

 

Best Regards,

Neeko Tang

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

4 REPLIES 4
v-tangjie-msft
Community Support
Community Support

Hi @Rustynom ,

 

According to the document, measures only consume memory during calculations and have better performance than computed columns. We recommend that you create a measure.

Measure_need = 
var _followdate=CALCULATE(MAX('Follow-Ups'[Follow-uo reply date]),FILTER('Follow-Ups','Follow-Ups'[User ID]=RELATED('Responses'[User ID])))
return 
IF(_followdate>SELECTEDVALUE('Responses'[Latest Response Date]),"Yes","No")

vtangjiemsft_1-1671762568221.png

Then the result is as follows.

vtangjiemsft_2-1671762599119.png

Best Regards,

Neeko Tang

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

Thank you for the reply on this. I tried implementing your recommendation here, however I'm unable to structure the relationships in a way that will allow the RELATED('Responses'[User ID]) to be recognized by the measure.
I've also tinkered around with your attached file and below is the error I get when attempting to append additional data to both of the test datasets.

Rustynom_0-1671821009606.png

 

It seems the relationship cannot be structured as many to one if duplicates are contained within both data sets. Because we are measuring only the latest of a list follow-up replies against a list of many responses, both datasets will contain duplicate user IDs.
If there is some way of transforming the follow-up table’s duplicate User ID's to keep the rows with the latest follow-up reply date, that would probably let me implement your measure.

Hi @Rustynom ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1672035274836.pngvtangjiemsft_1-1672035288746.png

vtangjiemsft_2-1672035321062.png

 

(2) We can create a calculated column.

Needs Follow-up = var _maxdate=MAXX(FILTER('Follow-Ups',[User ID]=Responses[User ID]),[Follow-uo reply date])

 return IF(_maxdate>=[Latest Response Date],"Yes","No")

(3) Then the result is as follows.

vtangjiemsft_3-1672035364802.png

 

Best Regards,

Neeko Tang

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

This worked! Thank you!

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Top Kudoed Authors