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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Mark88
Frequent Visitor

Filter value from a column

Hi,

 

I have a data set of more then 1M data lines. Below is a sample of this data set. The ID column is a text field and the ID's appear multiple times because they are active on multiple measurement dates. The measurement date is not unique, because multiple ID's can have the same measurement date. The last column contains the temperature measured on the specific date/time.

 

IDMeasurementDate                   Temperature                             
63473G861508034100123115-1-2019 10:5020,6
63473G861508034100123115-1-2019 11:0020,6
63473G861508034100123115-1-2019 11:1020,6
63473G861508034100123115-1-2019 11:2020,6
63473G861508034100123115-1-2019 11:3020,6
63473G861508034100123115-1-2019 11:4020,6
63473G861508034100123115-1-2019 11:5020,6
63473G861508034100123115-1-2019 12:0020,6
63473G861508034100123115-1-2019 12:1020,6
63473G861508034100123115-1-2019 12:2020,5
63473G861508034100123215-1-2019 10:5020,8
63473G861508034100123215-1-2019 11:0020,8
63473G861508034100123215-1-2019 11:1020,8
63473G861508034100123215-1-2019 11:2020,8
63473G861508034100123215-1-2019 11:3020,8
63473G861508034100123215-1-2019 11:4020,8
63473G861508034100123215-1-2019 11:5020,8
63473G861508034100123215-1-2019 12:0020,8
63473G861508034100123215-1-2019 12:1020,8
63473G861508034100123215-1-2019 12:2020,9
63473G861508034100123315-1-2019 10:5020,9
63473G861508034100123315-1-2019 11:0020,9
63473G861508034100123315-1-2019 11:1020,9
63473G861508034100123315-1-2019 11:2020,9
63473G861508034100123315-1-2019 11:3020,9
63473G861508034100123315-1-2019 11:4020,9
63473G861508034100123315-1-2019 11:5020,9
63473G861508034100123315-1-2019 12:0020,9
63473G861508034100123315-1-2019 12:1020,9
63473G861508034100123315-1-2019 12:2020,8

 

I want to create a new column that only shows the last temperature measured by the ID. These are the bold temperatures in my example. Can you please advise what formula I can use to arrange this?

1 ACCEPTED SOLUTION

Try these calculated columns;
DateRank = RANKX(FILTER(TempTable,TempTable[ID]=EARLIER(TempTable[ID])),TempTable[MeasurementDate],,DESC)

LastTemperatureReading = MINX(FILTER(TempTable,TempTable[ID]=EARLIER(TempTable[ID])&&TempTable[DateRank]=1),TempTable[Temperature])

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Mark88 ,

You can create a measure as below to get the last temperature:

Latest temperature = 
CALCULATE (
    MAX ( 'Measurement'[Temperature] ),
    FILTER (
        'Measurement',
        'Measurement'[ID] = MAX ( 'Measurement'[ID] )
            && 'Measurement'[MeasurementDate] = MAX ( 'Measurement'[MeasurementDate] )
    )
)

last temperature.JPG

Best Regards

Rena

AllisonKennedy
Super User
Super User

Not sure what the end goal is, this could be done using MEASURES, but if you absolutely need it as a column please explain why so we can provide more helpful response. You may be able to achieve it using the EARLIER function inside a calculated COLUMN.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedyThe actual table I have contains more columns. I require this measure in a seperate column (in the same table) because it's part of a couple of measurements I need to implement in this table to prepare my data. Most of the other measurements I already found out myself, but this one I'm unable to solve.

 

So in order to get my final result, I require this measurement in in a new column in the same table. I already tried to work with the EARLIER function, but I can't make it work.

Try these calculated columns;
DateRank = RANKX(FILTER(TempTable,TempTable[ID]=EARLIER(TempTable[ID])),TempTable[MeasurementDate],,DESC)

LastTemperatureReading = MINX(FILTER(TempTable,TempTable[ID]=EARLIER(TempTable[ID])&&TempTable[DateRank]=1),TempTable[Temperature])

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedyThanks a lot for your help! The RANKX formula helped me to solve the issue. The MINX formula also worked, but this showed me the last temperature in every cell of the column. I only needed the last temperature and the other cells being blank. I solved this via an IF formula.

 

Also thanks to @Anonymous and @amitchandak for your time!

amitchandak
Super User
Super User

@Mark88 , This should work as a measure along with ID

lastnonblankvalue(Table[MeasurementDate],Table[Temperature])

new Table

Summarize(Table,Table[ID], "Last Value",lastnonblankvalue(Table[MeasurementDate],Table[Temperature]))

 

New Measure =

Sumx(Summarize(Table,Table[ID], "Last Value",lastnonblankvalue(Table[MeasurementDate],Table[Temperature])),[Last Value])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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