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
Anonymous
Not applicable

Calculating whether record is the latest record in date range

Hello

 

I work for an organisation where operators submit returns giving their financial details.  Each return has a start and end date which is not the same for each operator.  Some operators submit quarterly or some submit annually.  I need to create a report that lists all the returns that fall within a certain reporting period (in the case 01/04/2017 to 31/03/2018) and I need to flag the latest return within that reporting period for each operator.  I am struggling to write this with DAX and have an added complication is that I'm using direct query due to the size of the tables and need to use measures rather than calculated columns.  Below is an example of the data and Islastreturnforreportingperiod? column is what I want to acheive.  I hope someone can help.  Thanks in advance Jo.

 

 

sampledata.PNG

1 ACCEPTED SOLUTION

@Anonymous  Please try this as a New Measure.

 

Test254Flag = 
VAR _MaxEnd = CALCULATE(MAX(Test254FlagLatest[EndDate]),ALLEXCEPT(Test254FlagLatest,Test254FlagLatest[AccountNo]))
RETURN IF(MAX(Test254FlagLatest[EndDate]) = _MaxEnd,"Yes","No")

image.png





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

Proud to be a PBI Community Champion




View solution in original post

4 REPLIES 4
PattemManohar
Community Champion
Community Champion

@Anonymous  Thanks for the sample data. Please post the same in copiable format which will be helpful.

 





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

Hi @PattemManohar 

 

Thanks for your reply.  I've attached the dataset.

 

Thanks

 

 

Account NoOperator NameReturnNumberReporting_PeriodReturn StartdateReturn EnddateValueIslastreturnforreporting period?

2Bob1-13431659101/04/2017-31/03/201801/01/201831/03/2018113Yes
2Bob1-12574952101/04/2017-31/03/201801/07/201730/09/201797No
3Fred1-11565965101/04/2017-31/03/201801/04/201730/06/201739No
3Fred1-11958004101/04/2017-31/03/201801/07/201730/09/201786Yes
4Murphy1-13431673101/04/2017-31/03/201801/07/201730/09/201747No
4Murphy1-12574966101/04/2017-31/03/201801/10/201731/12/201732Yes
5Simon1-11566126101/04/2017-31/03/201801/04/201730/06/201761No
5Simon1-13431767101/04/2017-31/03/201801/07/201731/10/2017116Yes
6Ted1-12220042101/04/2017-31/03/201825/07/201724/10/201738No
6Ted1-12220233101/04/2017-31/03/201825/01/201824/04/201886Yes
7Alan1-11957865101/04/2017-31/03/201801/04/201730/06/20177No
7Alan1-12779180101/04/2017-31/03/201801/07/201730/09/201719Yes

@Anonymous  Please try this as a New Measure.

 

Test254Flag = 
VAR _MaxEnd = CALCULATE(MAX(Test254FlagLatest[EndDate]),ALLEXCEPT(Test254FlagLatest,Test254FlagLatest[AccountNo]))
RETURN IF(MAX(Test254FlagLatest[EndDate]) = _MaxEnd,"Yes","No")

image.png





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

thank you @PattemManohar  it works!

I've been puzzling over this for a long time.

 

Thanks again

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.