Forum Discussion

Jay2077's avatar
Jay2077
Helper III
5 years ago
Solved

DAX MAXX function assistance

Playing around with the MAXX function and I want to get the longest song 

 

My table is set up as song title in one column followed by length in the next column, 

 

I want to either find out the longest song just 'time', eg 7.20 or the longeest song title and time, eg Here Comes The Sun, 3.40 etc

 

I did this as a new column from the table, i'm not sure i'm getting the correct result 

 

Longest Song =
MAXX(
RELATEDTABLE('Abbey Road'),'Abbey Road'[Length])

 

Any help greatly appreciated  

  • Hi Jay2077 

    You can take steps below for reference:

    Create the measures:

    longesttimesong = MAXX(ALL('Table'),'Table'[Length])
    longesttimesongtitle =
    VAR title =
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Song Title] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Length] = [longesttimesong] )
        )
    RETURN
        title & ", " & [longesttimesong]

    result:

    Hope it helps.

     

    Best Regards,

    Community Support Team _ Tang

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

7 Replies

    • Jay2077's avatar
      Jay2077
      Helper III

      I can't seem to add xlx or pbix files for some reason its just one table anyway

  • Like so 

     

    longesttimesongtitle =
    CALCULATE (
    SELECTEDVALUE ( 'Abbey Road'[Song Title] ),
    FILTER ( ALL ( 'Abbey Road' ), 'Abbey Road'[Length] = [longesttimesong] )
    )
    RETURN
    title & ", " & [longesttimesong]
    • v-xiaotang's avatar
      v-xiaotang
      Community Support

      Hi Jay2077 

      Hope it helps.

       

      Best Regards,

      Community Support Team _ Tang

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