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
Anonymous
Not applicable

How to display just one top result in a PBI Card visualization

Hi, I need some help in coding the DAX. I came across this website https://blog.enterprisedna.co/showcase-the-top-result-name-within-a-card-visualization-using-power-b...and I tried to follow the coding for my case. But it does not work in my case. 

 

I am sharing the sample data and coding here. 

 

zxavierdeloitte_0-1606717019175.png

Program Table

zxavierdeloitte_1-1606717125193.png

If I click on FY 20, it should reflect the top program attended by participants. In my case, it shows blank value.

Not sure whether I have coded in a wrong way.

zxavierdeloitte_0-1606717438749.png

 

2 ACCEPTED SOLUTIONS
AlB
Super User
Super User

@Anonymous 

Ok, then you just need  TOPN(1,...   instead of TOPN( 2,...

 

 

Top Prog =
CONCATENATEX (
    TOPN (
        1,
        DISTINCT ( Program[Programme Name] ),
        [Total no of program attendees], DESC
    ),
    Program[Programme Name],
    ", "
)

 

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

View solution in original post

Anonymous
Not applicable

8 REPLIES 8
Anonymous
Not applicable

Thanks! @AlB @amitchandak 

AlB
Super User
Super User

@Anonymous 

Ok, then you just need  TOPN(1,...   instead of TOPN( 2,...

 

 

Top Prog =
CONCATENATEX (
    TOPN (
        1,
        DISTINCT ( Program[Programme Name] ),
        [Total no of program attendees], DESC
    ),
    Program[Programme Name],
    ", "
)

 

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

AlB
Super User
Super User

Hi @Anonymous 

Try this:

Top 2 Prog =
CONCATENATEX (
    TOPN (
        2,
        DISTINCT ( Program[Programme Name] ),
        [Total no of program attendees], DESC
    ),
    Program[Programme Name],
    ", "
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

@AlB 

THanks it works! But as for the case where there is only 1 program with the highest no of attendees, I just would need only 1 program name that will be displayed. If there are any other 2 programs with the same highest no of attendees, then I will need 2 programs to be displayed. 

 

Currently, based on your solution, I have 2 different program names with different no of attendees. But I would want only 1 program name if there is no other program with the same highest no of attendees.

 

Case 1:

Program A: 100 people

Program B: 90 people

 

Then the card should show "Program A"

 

Case 2

Progam A: 100 people

Program B: 100 people

 

Then the card should show " Program A, Program B"

Thanks!

amitchandak
Super User
Super User

@Anonymous ,

Try like example

Top 1Rank = CALCULATE(max(Program[Program Name]),TOPN(1 ,all(Program[Program Name]),[Sales],DESC),VALUES(Program[Program Name]))

 

https://www.youtube.com/watch?v=QIVEFp-QiOk

Anonymous
Not applicable

@amitchandak 

Thanks! It works. However in one of the FYs, I have more than 1 result that shows the highest no. How to display more than 1 result at the same time in the Card visualisation?

 

For example

 

"Program 1 & Program 2"

Most popular courses

@Anonymous , Try like

Top 2 Rank = CALCULATE(concatenatex(Program,Program[Program Name]),TOPN(2 ,all(Program[Program Name]),[Sales],DESC),VALUES(Program[Program Name]))

Anonymous
Not applicable

@amitchandak 

It works but the outcome is not quite right. 

When I select one FY, it shows that type of program name more than once. Even if there are two different programs that have the same highest no of attendees, it does not give me two different program names.

 

Top 2 Prog =
CALCULATE(CONCATENATEX(Program,Program[Programme Name]), TOPN(2,all(Program[Programme Name]),[Total no of program attendees], DESC), VALUES(Program[Programme Name]))

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.