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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ehmacc
Frequent Visitor

Returning the Max Date for a set, with an added filter

I am trying to create a new column on a table that is a Max calculation with a filter- in this instance, I need to return the Max Date but only if the Rate Change was grater than 0 (example table below).

 

Right now I am using an equation that returns the Max Date for Each ID, but I need to filter that return to only be if that date was associated with an increase 

 

Current equation-

Most Recent Rate Change = CALCULATE(max (EmploymentHistory[Date]), ALLEXCEPT(EmploymentHistory, EmploymentHistory[Id]))
 
IDDateRate Change

Current Date returned

Most Recent Rate Change (DESIRED RESULT)
17/3/190%7/3/196/8/19
16/8/194%7/3/196/8/19
15/1/183%7/3/196/8/19
28/8/192%8/8/198/8/19
22/17/187%8/8/198/8/19

 

I have tried to build the filter into the equation in multiple ways, and keep failing, I need it as part of the equation rather than a filter on a visual or table becuase it will be built used 

1 ACCEPTED SOLUTION
lc_finance
Solution Sage
Solution Sage

Hi @ehmacc ,

 

 

You can use the following formula:

 

Most recent rate change (calculated) = 

CALCULATE(LASTDATE('EmploymentHistory'[Date]), ALLEXCEPT('EmploymentHistory','EmploymentHistory'[ID]), 'EmploymentHistory'[Rate Change]>0)

Basically I added one more condition to the CALCULATE filter: rate should be higher than 0.

 

Here is a screenshot of what it looks like.

Most recent rate change.png

 

Finally, here is a Power BI file with the new formula.

 

Does this help you? Let me know if you have further questions,

 

LC

Interested in Power BI and DAX templates? Check out my blog at www.finance-bi.com

View solution in original post

3 REPLIES 3
lc_finance
Solution Sage
Solution Sage

Hi @ehmacc ,

 

 

You can use the following formula:

 

Most recent rate change (calculated) = 

CALCULATE(LASTDATE('EmploymentHistory'[Date]), ALLEXCEPT('EmploymentHistory','EmploymentHistory'[ID]), 'EmploymentHistory'[Rate Change]>0)

Basically I added one more condition to the CALCULATE filter: rate should be higher than 0.

 

Here is a screenshot of what it looks like.

Most recent rate change.png

 

Finally, here is a Power BI file with the new formula.

 

Does this help you? Let me know if you have further questions,

 

LC

Interested in Power BI and DAX templates? Check out my blog at www.finance-bi.com

Nathaniel_C
Super User
Super User

Hi @ehmacc ,
You were almost there. Just needed a condition. Let me know if this works for you...it is a measure

 

Most Recent Rate Change = CALCULATE(MAX(EmploymentHistory[Date]),Filter(ALLEXCEPT(EmploymentHistory,EmploymentHistory[ID]),EmploymentHistory[Rate Change]<>0))

 

rate chg.PNG

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you so much!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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