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
ATZoeTang
Frequent Visitor

How to get the last value of the day for each day by name

We want to get the lastest code smells # for each day by each Repo Name, so in the table below for 5/7/2024, we want to see Repo Name = A, Code Smells = 283619; Repo Name = B, Code Smells = 5079. For 5/8/2024, we want to see Repo Name = A, Code Smells = 290000; Repo Name = B, Code Smells = 6789.

ATZoeTang_0-1723024308670.png

 

The resulting dash would look something like this:

ATZoeTang_1-1723024324336.png

Your help would be greatly appreciated.

Thanks.

1 ACCEPTED SOLUTION
mickey64
Super User
Super User

Step 0: I use your data below.

mickey64_0-1723038023132.png

 

Step 1: I add 'Date' column and rename it on Power Query Editor.

    Rename: 'Date' --> 'Last Analysys Date Only'

mickey64_1-1723038078713.png

Step 2: I make 2 mesures below.

M_LatestTime = CALCULATE(MAX('DATA'[Last Analysys Date]),ALLEXCEPT('DATA',DATA[Repo Name],DATA[Last Analysys Date Only]))

 

M_MaxSmell = MAXX(FILTER('DATA','DATA'[Last Analysys Date]=[M_LatestTime]),'DATA'[CodeSmells])

 

Step 3: I make 2 Tables and a graph.

mickey64_2-1723038510418.png

 

 

 

View solution in original post

2 REPLIES 2
mickey64
Super User
Super User

Step 0: I use your data below.

mickey64_0-1723038023132.png

 

Step 1: I add 'Date' column and rename it on Power Query Editor.

    Rename: 'Date' --> 'Last Analysys Date Only'

mickey64_1-1723038078713.png

Step 2: I make 2 mesures below.

M_LatestTime = CALCULATE(MAX('DATA'[Last Analysys Date]),ALLEXCEPT('DATA',DATA[Repo Name],DATA[Last Analysys Date Only]))

 

M_MaxSmell = MAXX(FILTER('DATA','DATA'[Last Analysys Date]=[M_LatestTime]),'DATA'[CodeSmells])

 

Step 3: I make 2 Tables and a graph.

mickey64_2-1723038510418.png

 

 

 

Greg_Deckler
Super User
Super User

@ATZoeTang You will need an Index ( add in Power Query Editor ). Then you can create a Complex Selector like this:

Selector Measure = 
  VAR __CurrentIndex = MAX( 'Table'[Index] )
  VAR __Date = MAX( 'Table'[Last Analysis Date] )
  VAR __MaxIndex = MAXX( FILTER( ALL( 'Table' ), [Last Analysis Date] = __Date ), [Index] )
  VAR __Result = IF( __CurrentIndex = __MaxIndex, 1, 0 )
RETURN
  __Result

You then filter your visual for Selector Measure = 1. The Complex Selector - Microsoft Fabric Community



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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.