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
markhomer
Frequent Visitor

Return the date a max value was recorded to produce a 'days since top score' visual

Hi All,

 

I have been struggling with this

 

I have a table of data that includes a date and 'score'. I would like a measure that returns the date that the maximum value was recorded. Using the below example, I would like the measure to return 01/02/2019. I have a measure that calculates the max value. My ultimate aim is to calculate the days between the best score and today so I can have a 'days since best score' visual.

 

Date                     Score

01/01/2019          3

01/02/2019          5

01/03/2019          1

01/04/2019          2

01/05/2019          3

01/06/2019          4

 

thanks in advance,

 

Mark

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @markhomer ,

I created a measure to calculate the date difference between the date of maximum score(01/02/2019) and today(10/9/2019) and I put the results into a card visual. You can have a try.

days since best score = 
var a = MAX('Table'[Score])
var b = CALCULATE(MAX('Table'[Date]),FILTER('Table','Table'[Score] = a))
return
DATEDIFF(b,TODAY(),DAY)

2.PNG

Best Regards,

Xue Ding

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

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

View solution in original post

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @markhomer ,

I created a measure to calculate the date difference between the date of maximum score(01/02/2019) and today(10/9/2019) and I put the results into a card visual. You can have a try.

days since best score = 
var a = MAX('Table'[Score])
var b = CALCULATE(MAX('Table'[Date]),FILTER('Table','Table'[Score] = a))
return
DATEDIFF(b,TODAY(),DAY)

2.PNG

Best Regards,

Xue Ding

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

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

That works perfectly - many thanks @v-xuding-msft 

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.