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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
POSPOS
Post Patron
Post Patron

How to show latest status based on date

Hi All,

I have a table with three columns - Date, Emp, Status.

My requirement is to create a dax formula to show the latest status.

I have a sample data attached in this file 

POSPOS_0-1728336612742.png

Required output is :

EmpStatus
E1Active
E2Active
E3Terminated

 

Based on the latest date, need to look for the latest status. Can some one pls suggest with a solution for this?

Thank you.

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

@POSPOS 

 

Download PBIX file with the example below

 

Try this, works for me

 

 

Latest Status = 

VAR _latest_date = CALCULATE(MAX('Sheet1'[Date]), FILTER(ALL('Sheet1'), 'Sheet1'[Emp] = SELECTEDVALUE(Sheet1[Emp])))

RETURN CALCULATE(MAX('Sheet1'[Status]), FILTER('Sheet1', 'Sheet1'[Emp] = SELECTEDVALUE(Sheet1[Emp]) && 'Sheet1'[Date] = _latest_date))

 

 

PhilipTreacy_0-1728345918126.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1728357768132.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-kaiyue-msft
Community Support
Community Support

Hi @POSPOS ,

 

Your solution is great, collinq  and PhilipTreacy . It worked like a charm! Here I have another idea in mind, and I would like to share it for reference. 

 

you can use the following DAX formula in Power BI to get the latest status for each employee.

LatestStatus = 
VAR LatestDate = 
    CALCULATE(
        MAX('Sheet1'[Date]),
        ALLEXCEPT('Sheet1', 'Sheet1'[Emp])
    )
RETURN
    CALCULATE(
        VALUES('Sheet1'[Status]),
        'Sheet1'[Date] = LatestDate,
        ALLEXCEPT('Sheet1', 'Sheet1'[Emp])
    )

vkaiyuemsft_0-1728355807424.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

collinq
Super User
Super User

Hey @POSPOS ,

 

There are many ways to do this I am sure but I did it by creating a new table in DAX with this command:

MostRecentStatusTable =
ADDCOLUMNS(
    SUMMARIZE(
        'Sheet1',
        'Sheet1'[EMP],
        "MostRecentDate", MAX('Sheet1'[Date])
    ),
    "MostRecentStatus",
    VAR MostRecentDateForEMP = [MostRecentDate]
    RETURN
        CALCULATE(
            MAX('Sheet1'[Status]),
            'Sheet1'[Date] = MostRecentDateForEMP
        )
)
 
And, that gave me the result that you were looking for:
collinq_0-1728347229254.png

 

 

 




Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!
Private message me for consulting or training needs.




PhilipTreacy
Super User
Super User

@POSPOS 

 

Download PBIX file with the example below

 

Try this, works for me

 

 

Latest Status = 

VAR _latest_date = CALCULATE(MAX('Sheet1'[Date]), FILTER(ALL('Sheet1'), 'Sheet1'[Emp] = SELECTEDVALUE(Sheet1[Emp])))

RETURN CALCULATE(MAX('Sheet1'[Status]), FILTER('Sheet1', 'Sheet1'[Emp] = SELECTEDVALUE(Sheet1[Emp]) && 'Sheet1'[Date] = _latest_date))

 

 

PhilipTreacy_0-1728345918126.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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