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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
lastnn30
Post Patron
Post Patron

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

 

SNAG-0721.jpg

2 ACCEPTED SOLUTIONS
edhans
Super User
Super User

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

Try this measure:

edhans_0-1653350687130.png

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

CNENFRNL
Community Champion
Community Champion

Record_2022_05_24_06_11_05_56.gif


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
CNENFRNL
Community Champion
Community Champion

Record_2022_05_24_06_11_05_56.gif


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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

edhans
Super User
Super User

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

Try this measure:

edhans_0-1653350687130.png

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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

Glad to assist @lastnn30 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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