Forum Discussion

lastnn30's avatar
lastnn30
Post Patron
4 years ago
Solved

Top N using Card visual

Hi

I have 2 fields, Name and Total. I want to create 2 cards, one to show the name of the person who scored the highest and the second card to show the highest number. for the highest number, it works fine but for the name, it did not. Please see the screenshot below also the source file link is below. Any help would be very much appreciated. Thanks

 

https://drive.google.com/file/d/1ziZgvMe8JDU4PB7PNWVozvZsluuJiCUR/view?usp=sharing

 

  • Hi lastnn30 - you cannot filter cards the same way you can tables and other visuals since they only return one value.

    Try this measure:

    Top Name = 
    VAR varTopValue = MAX('Latest File'[Total])
    VAR Result =
        MAXX(
            FILTER(
                'Latest File',
                'Latest File'[Total] = varTopValue
            ),
            'Latest File'[Name]
        )
    RETURN
        Result

     

    It gets the top value in that table, then gets the name of that person. MAXX() here is just converting the name to a scalar value, not returning the hightest name. the FILTER() function is returning a single record with Mark's data.

5 Replies

  • edhans's avatar
    edhans
    Community Champion

    Hi lastnn30 - you cannot filter cards the same way you can tables and other visuals since they only return one value.

    Try this measure:

    Top Name = 
    VAR varTopValue = MAX('Latest File'[Total])
    VAR Result =
        MAXX(
            FILTER(
                'Latest File',
                'Latest File'[Total] = varTopValue
            ),
            'Latest File'[Name]
        )
    RETURN
        Result

     

    It gets the top value in that table, then gets the name of that person. MAXX() here is just converting the name to a scalar value, not returning the hightest name. the FILTER() function is returning a single record with Mark's data.

    • lastnn30's avatar
      lastnn30
      Post Patron

      Thank you so much for your help. I appreciate it.