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
HeatherBisher
Regular Visitor

Dax statement to display data in one column based on most recent entry or max date

I am trying to write a Dax for a New Measure to display or filter the most recent entry for a Class (this is entered many times) and the Current class Number ( again entered many times and can change) but needing the most recent number.

Here is a look at My Data 

HeatherBisher_0-1677101452163.png

as you can see I may have a class (115-23) with the Current # of agents entered several times I need to display only the most recent number of agents for each class Number. 

I have this but it only gets part of the way I cant get past the if Statement if the expression is true.. 

Is most recent =

var CurrentClassNumber= 'Form Data'[Class Number ]

var mostRecentDate = CALCULATE(MAX('Form Data'[Entry Date]),ALL('Form Data'),'Form Data'[Class Number ] = CurrentClassNumber)

return

IF('Form Data'[Entry Date] = mostRecentDate,"","0")

 

Any help would be great I am a relitivly new user comeing from Excel and hitting road blocks.

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @HeatherBisher ,

 

According to your statement, I think your requirement is to show data on most recent date each class number. Here I suggest you to filter your visual by measure in visual level filter.

Is most recent = 
VAR CurrentClassNumber =
    MAX ( 'Form Data'[Class Number] )
VAR mostRecentDate =
    CALCULATE (
        MAX ( 'Form Data'[Entry Date] ),
        ALL ( 'Form Data' ),
        'Form Data'[Class Number] = CurrentClassNumber
    )
RETURN
    IF ( MAX ( 'Form Data'[Entry Date] ) = mostRecentDate, 1, 0 )

Add this measure into visual level filter and set it to show items when value = 1.

RicoZhou_0-1677566557274.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @HeatherBisher ,

 

According to your statement, I think your requirement is to show data on most recent date each class number. Here I suggest you to filter your visual by measure in visual level filter.

Is most recent = 
VAR CurrentClassNumber =
    MAX ( 'Form Data'[Class Number] )
VAR mostRecentDate =
    CALCULATE (
        MAX ( 'Form Data'[Entry Date] ),
        ALL ( 'Form Data' ),
        'Form Data'[Class Number] = CurrentClassNumber
    )
RETURN
    IF ( MAX ( 'Form Data'[Entry Date] ) = mostRecentDate, 1, 0 )

Add this measure into visual level filter and set it to show items when value = 1.

RicoZhou_0-1677566557274.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.