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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Get Minimum Date per Category based on Minimum Value per Category

Hi,

 

I need some help for a relative "simple" problem . I have a table with values per date and category.

Now I would like to see the minimum value per category and its RELATED minimum date.

However I'm not succeeding in adding the "minimum" date for the "minimum" value.  You should note that the minimum date is related/dependent on the "minimum" value, so I'm not interested in the minimum date per category but rather the date where the minimum value took place.

 

Here is an example in excel, how can I do this in DAX ?

 

Requested result is Category + mIn value + min dateRequested result is Category + mIn value + min date

 

In SQL code, I would do it like this:

SELECT t0.Category,Min(Date) as MinDate, Min(t1.MinValue) as MinValuePerCategory
FROM table t0
INNER JOIN
(
SELECT Category, Min(Value) as MinValue
FROM table
group by Category
) as t1

ON t0.Category=t1.Category
AND t0.Value=t1.MinValue

 

Many thanks

Tim

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Both as new columns

 

Min Value =
minx(filter(Table, [Category] = earlier([Category])),[Value])


Min Date =
minx(filter(Table, [Category] = earlier([Category]) && [Value] = [Min Value]),[Date])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Please try to create a measure.

Measure = CALCULATE(MIN('Table'[Date]),FILTER(ALL('Table'),[Category]=MAX('Table'[Category])&&[Value]=MAX('Table'[Value])))

If you have two tables, you can change it.

Measure = CALCULATE(MIN('Table'[Date]),FILTER(ALL('Table'),[Category]=MAX('Table'[Category])&&[Value]=MAX('t1'[Value])))

vyalanwumsft_0-1639453956646.png

The final output is shown below:

vyalanwumsft_2-1639454074060.png


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Both as new columns

 

Min Value =
minx(filter(Table, [Category] = earlier([Category])),[Value])


Min Date =
minx(filter(Table, [Category] = earlier([Category]) && [Value] = [Min Value]),[Date])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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