Forum Discussion

rantel's avatar
rantel
New Member
3 years ago
Solved

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? 

 

 

 

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))
    }

4 Replies

  • 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] )
    

     

    • rantel's avatar
      rantel
      New Member

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

    • rantel's avatar
      rantel
      New Member

      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] )