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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
olimilo
Post Prodigy
Post Prodigy

Get latest value based on max date as calculated column

Example data below:

ID Fty Status Date 
1 Facility A Active 1/1/2020 
2 Facility B Active 1/1/2021 
3 Facility A Active 1/1/2021 
4 Facility C Active 1/1/2022 
5 Facility A Inactive 1/1/2022 
6 Facility B Active 1/1/2023 

 

I'm trying to get the Status of the Facility based on the Date column. I am able to do this as a measure below however I would like to get it as a calculated column?

 

Expected output:

Fty Status 
Facility A Inactive 
Facility B Active 
Facility C Active 

 

 

~Current Status = 
    VAR _val = MAX('Data'[Date])
    RETURN
        MAXX(
            FILTER(
                'Data',
                'Data'[Date] = _val && 'Data'[Fty] = MAX('Data'[Fty])
            ),
            'Data'[Status]
        )

 

 

2 REPLIES 2
v-weiyan1-msft
Community Support
Community Support

Hi @olimilo ,

 

@talespin nice method!And you can also consider using the following code to meet your needs.
Based on your description, please try code as below to create a Calcualted table.

New Table =
VAR MaxDate =
    MAXX ( ALLEXCEPT ( 'Table', 'Table'[Fty] ), 'Table'[Date] )
VAR TempTable =
    ADDCOLUMNS (
        VALUES ( 'Table'[Fty] ),
        "Status",
            MAXX (
                FILTER (
                    'Table',
                    'Table'[Fty] = EARLIER ( 'Table'[Fty] )
                        && 'Table'[Date] = [MaxDate]
                ),
                'Table'[Status]
            )
    )
RETURN
    TempTable

Result is as below.

vweiyan1msft_0-1706582054909.png


Best Regards,
Yulia Yan

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

talespin
Solution Sage
Solution Sage

hi @olimilo ,

 

Please test this.

First calculating max date for each facility by removing all filters on table except facility.

Then using this date to find the status for each facility.

 

CurrentStatus =
VAR _fty = TestTable7[Fty]
VAR _maxDateFty = CALCULATE(MAX(TestTable7[Date]), REMOVEFILTERS(TestTable7), TestTable7[Fty] = _fty)
return CALCULATE(MAX(TestTable7[Status]), REMOVEFILTERS(TestTable7), TestTable7[Fty] = _fty && TestTable7[Date] = _maxDateFty)
 

talespin_0-1706535641067.png

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.