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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
FrankWe
Helper II
Helper II

Need a Calculated Column "Latest Rate" containing latest value of column "Rate" per value in"_id"

Hello,

 

I would like to create a calculated column called "Latest Rate". This column should contain the latest value from column "Rate" per ID in column "_id". All rows with the same ID should all have the latest value of column "Rate" in the calculated column "Latest Rate". 

 

What I have so far is, that I am able to find out the last date per _id with the following function:

 

LastDatePerID = CALCULATE(
    MAX[Date] ),
    ALLEXCEPT( MyDataTable, MyDataTable[_id])
    )
 
How can I now get the value from column "Rate" for the "LastDatePerID" and write it to all rows to column "Latest Rate" having the same _id?

 

I hope that the example table below will help to understand what I would like to create.

 

_id

Date

Rate

Latest Rate

1

01.01.2024

295,00 €

287,00 €

1

03.01.2024

290,00 €

287,00 €

1

04.01.2024

287,00 €

287,00 €

2

02.01.2024

345,00 €

365,00 €

2

03.01.2024

365,00 €

365,00 €

3

01.01.2024

145,00 €

125,00 €

3

02.01.2024

153,00 €

125,00 €

3

05.01.2024

139,00 €

125,00 €

3

07.01.2024

125,00 €

125,00 €

 

Many thanks in advance for your help.

 

Frank

1 ACCEPTED SOLUTION

hi, @FrankWe 

try below

 

Column = 
var a = MAXX( FILTER('Table (2)', [id]=EARLIER([id])),[date])
var b = MAXX( FILTER('Table (2)',[id]= EARLIER([id]) && [date]=a),[rate])
return
b

 

Dangar332_0-1704963806877.png

 

View solution in original post

4 REPLIES 4
Dangar332
Super User
Super User

hi, @FrankWe 

 

try below

latest rate =
var LastDatePerID = 
     CALCULATE(
    MAX( [Date] ),
    ALLEXCEPT( MyDataTable, MyDataTable[_id])
    )   -- your code for latest date per id

return
calculate(
   max(MyDataTable[Rate]),
   values(MyDataTable[_id]),
   MyDataTable[Date]=  LastDatePerID 
)

Hi,

I tried it but it is not doing what I need to have. The result now looks like this:

 

_id

Date

Rate

Latest Rate

1

01.01.2024

295,00 €

 

1

03.01.2024

290,00 €

 

1

04.01.2024

287,00 €

287,00 €

2

02.01.2024

345,00 €

 

2

03.01.2024

365,00 €

365,00 €

3

01.01.2024

145,00 €

 

3

02.01.2024

153,00 €

 

3

05.01.2024

139,00 €

 

3

07.01.2024

125,00 €

125,00 €

 

But I need to have this

 

_id

Date

Rate

Latest Rate

1

01.01.2024

295,00 €

287,00 €

1

03.01.2024

290,00 €

287,00 €

1

04.01.2024

287,00 €

287,00 €

2

02.01.2024

345,00 €

365,00 €

2

03.01.2024

365,00 €

365,00 €

3

01.01.2024

145,00 €

125,00 €

3

02.01.2024

153,00 €

125,00 €

3

05.01.2024

139,00 €

125,00 €

3

07.01.2024

125,00 €

125,00 €

 

With your solution a value is only written in column "Latest Rate" when the row contains the latest date in column "Date".  But I need to have the value written to all rows having the same id in column "_id"

hi, @FrankWe 

try below

 

Column = 
var a = MAXX( FILTER('Table (2)', [id]=EARLIER([id])),[date])
var b = MAXX( FILTER('Table (2)',[id]= EARLIER([id]) && [date]=a),[rate])
return
b

 

Dangar332_0-1704963806877.png

 

Hi Dangar332,

 

I tried your solution and it is working 😀 

 

Many thanks for your help. 

 

Frank

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.