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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
ali_b
Advocate I
Advocate I

How do I get the latest metric value available in a metric table, ordered by a calendar table?

Hi,

Going mad here. I have a simple model with a calendar (days granularity), and metric table (one row per metric / day), joined on a one to many with cross filtering in both directions (joined on Date column).

The metric table looks like this:
"date",  "metric value"

d1, 1

d3, 2

The calendar table has values d0 to d10 or whatever (no other columns).

I want to create a measure (not a table, not m code, a measure) which produces the latest available metric value. So for five days it would look like:
d0, null,

d1, 1,

d2, 1,

d3, 2,

d4, 2,

...

d1000, 2

 

Closest I've gotten is:

Measure =
    var t = FILTER(all(Metrics), RELATED('Calendar'[Date]) <= Metrics[Date])
    var v = TOPN(1, t, Metrics[Date], DESC)    
    VAR x = maxx(v, Metrics[Goal])
    return x
 
But this produces:
d0,2
d1,2
d2,2
d3,2
d4,2
...
So it's not actually filtering on the calendar date range.
Any ideas?
Thanks in advance!
A

 

 

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@ali_b 

you can try this. 

Do not create relationships between two table

then create a measure

 

Measure =
var _date=maxx(FILTER('Table','Table'[Date]<=max('date'[Date])),'Table'[Date])
return if(ISBLANK(_date),"null",maxx(FILTER('Table','Table'[Date]=_date),'Table'[metric value]))
 
11.png
 
pls see the attachment below




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

Proud to be a Super User!




View solution in original post

7 REPLIES 7
v-echaithra
Community Support
Community Support

Hi @ali_b ,

We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.

Best Regards,
Chaithra E.

v-echaithra
Community Support
Community Support

Hi @ali_b ,

May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.

Thank you.

HarishKM
Memorable Member
Memorable Member

@ali_b Hey,
I will  use this measure that retrieves the latest available metric value relative to each date in your calendar, you'll need to ensure the measure respects the date context provided by your calendar table.

 

LatestMetricValue =
VAR LatestMetricDate =
CALCULATE (
MAX ( Metrics[Date] ),
FILTER ( ALL ( Metrics ), Metrics[Date] <= MAX ( 'Calendar'[Date] ) )
)
RETURN
CALCULATE ( MAX ( Metrics[MetricValue] ), Metrics[Date] = LatestMetricDate )

 

Note: This measure efficiently filters and respects the context of each date in your calendar.

 


Thanks

Harish M

Kudos will be appriciated and accpet it as solution if it solves your problem

 

v-echaithra
Community Support
Community Support

Hi @ali_b ,

Thank you @Greg_Deckler , @ryan_mayu  for your inputs.

I hope the information provided is helpful.I wanted to check whether you were able to resolve the issue with the provided solutions.Please let us know if you need any further assistance.

Thank you.

ryan_mayu
Super User
Super User

@ali_b 

you can try this. 

Do not create relationships between two table

then create a measure

 

Measure =
var _date=maxx(FILTER('Table','Table'[Date]<=max('date'[Date])),'Table'[Date])
return if(ISBLANK(_date),"null",maxx(FILTER('Table','Table'[Date]=_date),'Table'[metric value]))
 
11.png
 
pls see the attachment below




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

Proud to be a Super User!




Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Community Champion
Community Champion

@ali_b Should be something like this:

Measure =
  VAR __Day = MAX( 'Calendar'[Date] ) // assuming using Date from Calendar in visual
  VAR __MetricDate = MAXX( FILTER( ALL( 'Metrics' ), [Date] <= __Day ), [Date] )
  VAR __Result = MAXX( FILTER( ALL( 'Metrics' ), [Date] = __MetricDate )
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 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.