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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

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



Follow on LinkedIn
@ 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!:
DAX For Humans

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.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.