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

Last date Selection

Hi, 

 

I have the below dataset.  

SiteDate CompletedDaysLastClean
0.39.09.4 - Room2/13/2020 21:551
0.39.09.4 - Room2/18/2020 22:045
0.39.09.4 - Room2/21/2020 22:083
1-31-62 -  W/R2/14/2020 18:414
1-31-62 -  W/R2/18/2020 19:504
1-31-62 -  W/R2/19/2020 19:561
1-31-62 -  W/R2/20/2020 17:261
1-31-62 -  W/R2/21/2020 18:421
1-31-69 - PTW/R2/11/2020 20:371
1-31-69 - PTW/R2/14/2020 18:163
1-31-69 - PTW/R2/18/2020 19:454
1-31-69 - PTW/R2/19/2020 16:461
1-31-69 - PTW/R2/20/2020 16:351
1-31-69 - PTW/R2/21/2020 16:551

 

The column "DaysLastClean" is a calculated columns 

DaysLastClean =
VAR temp =
TOPN (1,FILTER (Routine,Routine[Site] = EARLIER ( Routine[Site] )
&& Routine[Date Completed] < EARLIER ( Routine[Date Completed] )
&& Routine[Status] = "Complete"
),Routine[Date Completed], DESC)
RETURN
DATEDIFF ( MINX ( temp, Routine[Date Completed]), Routine[Date Completed], DAY )
 
Quetsion= What I need to show is rows for the latest date only.
End result of the above table
 
SiteDate CompletedDaysLastClean
0.39.09.4 - Room2/21/2020 22:083
1-31-62 -  W/R2/21/2020 18:421
1-31-69 - PTW/R2/21/2020 16:551

 

Appreciate all help for a Measure or column to achieve the above result.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Refer

Measure = 
VAR __id = MAX ( 'Table'[Site] )
VAR __date = CALCULATE ( MAX( 'Table'[Date Completed] ), ALLSELECTED ( 'Table' ),  'Table'[Site] = __id ) 
RETURN CALCULATE ( max ( 'Table'[DaysLastClean] ), VALUES ( 'Table'[Site] ), 'Table'[Site] = __id, 'Table'[Date Completed] = __date )

 

Appreciate your Kudos.

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

I think you just need a table visualization with Site in it and Date set to an aggregation of Last and then your DaysLastClean?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

Refer

Measure = 
VAR __id = MAX ( 'Table'[Site] )
VAR __date = CALCULATE ( MAX( 'Table'[Date Completed] ), ALLSELECTED ( 'Table' ),  'Table'[Site] = __id ) 
RETURN CALCULATE ( max ( 'Table'[DaysLastClean] ), VALUES ( 'Table'[Site] ), 'Table'[Site] = __id, 'Table'[Date Completed] = __date )

 

Appreciate your Kudos.

Anonymous
Not applicable

@amitchandak - Thanks for the measure. The solution works perfectly.

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.