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
rantel
New Member

Use MIN in measure, calculated row wise without aggregation

How to get the MIN of two dates in a Measure function without any aggregation. This can be done using a computed column but the issue is that it is not computed dynamically. 

See screenshot:

EndDate: is a measure column coming from End_Calendar table and the slicer.

Expected output: For each row, I want the MIN date of the two columns ColDateEnd & EndDate. As shown MinEndDateCalculatedCol gives me the MIN of the two but it is calculated once when the column is added. I learned Measure is computed dynamically. But Measure works at an aggregation level whereas I want to compute the MIN for each row.

I'm a newbie to DAX. 

Any alternatives for computing the MIN for each row dynamically? 

 

rantel_0-1684380212602.png

rantel_2-1684381103178.pngrantel_3-1684381127922.png

 

rantel_1-1684381078749.png

 

Sample Table = {
    (1,"the first row",DATE(2019,1,1), DATE(2019,3,1)),
    (2,"the second row",Date(2020,4,12), DATE(2020,5,1)),
    (3,"the thrid row",Date(2020,5,12), DATE(2020,6,1))
    }
1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @rantel ,

 

How about this:

Measure = 
VAR _temp = { MIN ( 'Sample Table'[Value3] ), MIN ('Sample Table'[Value4]) }
RETURN
MINX ( _temp, [Value] )

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

4 REPLIES 4
tackytechtom
Super User
Super User

Hi @rantel ,

 

How about this:

Measure = 
VAR _temp = { MIN ( 'Sample Table'[Value3] ), MIN ('Sample Table'[Value4]) }
RETURN
MINX ( _temp, [Value] )

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Thanks Tom. This worked. Just had to do a small tweak to remove the MIN function call for the Measure column.

Measure = 
VAR _temp = { MIN ( 'Sample Table'[Value3] ), 'Sample Table'[Value4] }
RETURN
MINX ( _temp, [Value] )
danextian
Super User
Super User

Hi @rantel ,

 

You still have to aggregate. MIN function takes either a column or two expressions but not an expression and anotherr column. Wrap the date column in MIN, MAX or SELECEDVALUE to satisfy its requirement. Your formula should be:

=
MIN ( MIN ( 'Sample Table'[ColDateEnd] ), [EndDate] )

 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks for the quick response @danextian - I could not get this working. Since the other solution worked, I stopped exploring this. Thank you.

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.