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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
HeatherBisher
Frequent 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

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