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

FORMULA DAX - CALCULATE MIN(Value) and Then Last (Date)

Hi All,
I am looking to calculate the value of a Label filed about the the min value and max date.
Below is the sample data.
I need to calculate the Month Label about Max[Date] about Min[Value]

Year MonthValueMonth LabelDate
20160113Jan/1601/01/2016 04:00:00
20141110Nov/1402/11/2014 02:00:00
20150210Feb/1516/02/2015 07:00:00
20150110Jan/1505/01/2015 05:00:00
20150811Aug/1505/08/2015 02:00:00
20151111Nov/1501/11/2015 03:00:00
20151212Dec/1501/12/2015 04:00:00


I use this Dax Formula:
Measure Month Label= MINX(
KEEPFILTERS(VALUES('Table'[Month Label]));
CALCULATE(MAX('Table'[Month Label]);FILTER('Table';'Table'[Value]=min('Table'[Value]))))

Measure Day = MINX(
KEEPFILTERS(VALUES('Table'[Date]));
CALCULATE(MAX('Table'[Date]);FILTER('Table';'Table'[Value]=min('Table'[Value]))))

The result is:

Measure DayMeasure Month Label
16/02/2015 07:00:00Nov/14


but I expect the result is

Measure DayMeasure Month Label
16/02/2015 07:00:00Feb/15

 

Measure Day is correct becouse is max about Date while Measure Month Label is not correct becouse is max about a string.

I'm sure it's likely a simple solution and any help you can provide will be appreciated.

Thanks a lot
Luca









1 REPLY 1
amitchandak
Super User
Super User

You can format date to get month , of use dates in values or try to use date to get month

Measure Month Label= MINX(
KEEPFILTERS(VALUES('Table'[Month Label]));
CALCULATE(MAX('Table'[Date]);FILTER('Table';'Table'[Value]=min('Table'[Value]))))


Measure Month Label=
var _day =MINX(
KEEPFILTERS(VALUES('Table'[Date]));
CALCULATE(MAX('Table'[Date]);FILTER('Table';'Table'[Value]=min('Table'[Value]))))
return
 MINX(
KEEPFILTERS(VALUES('Table'[Month Label]));
CALCULATE(MAX('Table'[Date]);FILTER('Table';'Table'[Date]=_day)));

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

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.