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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
paulj1
Helper II
Helper II

Return Nearest Date and Value

This one is perplexing me.... Thought this would be easy... but no.

 

I have a situation where I have a tolerance that changes on an irregular frequency; such as...

Table.JPG

 

What I need is a way of putting a target line on a line chart, or table that shows the target for that day, so in table below the 7% tolerance would apply on all dates 01 March 2020 through to 11 March 2020, then 12 March 2020 to 24 March 2020 would be 5% etc etc.   Daily dates are in a Date Table called Calendar, and tables are joined Date to Date

Table2.JPG

 

I'd like to do this as a measure because Id want to use the daily tolerance in other measures and in graphs (eg do a line chartshowing daily performance vs tolerance for that day), I can do a calculated column in the calendar table if i have to, but would rather not.

 

Ive got this far, but it only returns a value on the specific day not the dates between...

 

DailyTolerance = CALCULATE(MINX(ToleranceTarget,ToleranceTarget[Target]), FILTER(ALLSELECTED('Calendar'),'Calendar'[Date] <= MAX(ToleranceTarget[Date])),VALUES(ToleranceTarget[Target]))

 

Any advice appreciated...

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Maybe:

 

Sum of Target Column in Date table =
  VAR __TargetDate = MAXX(FILTER(ALL('ToleranceTarget'),'ToleranceTarget'[Date] <= 'Date'[Date]),'ToleranceTarget'[Date])
  VAR __Target = MAXX(FILTER(ALL('ToleranceTarget'),'ToleranceTarget'[Date] = __TargetDate),[Target])
RETURN
  __Target

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Maybe:

 

Sum of Target Column in Date table =
  VAR __TargetDate = MAXX(FILTER(ALL('ToleranceTarget'),'ToleranceTarget'[Date] <= 'Date'[Date]),'ToleranceTarget'[Date])
  VAR __Target = MAXX(FILTER(ALL('ToleranceTarget'),'ToleranceTarget'[Date] = __TargetDate),[Target])
RETURN
  __Target

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg.... worked a treat.... id prefer a measure but a calculated column works... i have about 8 tolerances like this so it gets me going..

 

Thankyou again

 

Keep keep safe in these troubled times

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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