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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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