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
MarkCBB
Helper V
Helper V

Name of Top 1,2,3 Stores within a tooltip

Hi There,

 

I am looking to create a DAX Measure that results in the Name of the top performing Store, 2nd Store and 3rd Store within the current filter context. so there will be 3 item in the tool tip pop up. I am just looking for the Name of the store.

 

My database is set up in a standard Star layout with the following tables:

 

Fact

Stores

Products

Calendar

 

The measure that will determine the Top 1,2,3 store is based on the Units sales. 

 

I Goal is for the user to be able to hover over a Channel (many stores are within a Channel) and the tooltip will tell them the top 1,2 and 3rd Store based on the performance of Unit sales. 

 

here is a sample set of the data: 

DATA

 

Regards,

Mark B

1 ACCEPTED SOLUTION
danextian
Super User
Super User

hi @MarkCBB,

 

I'm not sure which among the fields in your dataset pertains to the store so I just assumed it is PLACE ID.

 

I created the following measures:

sum of units = 
SUM ( 'FACT'[UNITS] )
store rank =
RANKX ( ALL ( tblCHANNEL[PLACE ID] ), [sum of units] )

I am not sure how you want to displace your top 3 in the hover so I just created two top3 measures to be used as tooltips:

top 3 =
CALCULATE (
    CONCATENATEX (
        VALUES ( tblCHANNEL[PLACE ID] ),
        tblCHANNEL[PLACE ID],
        ", " & UNICHAR ( 10 )
    ),
    FILTER ( ALL ( tblCHANNEL[PLACE ID] ), [store rank] <= 3 )
)
Top 3 (w/ order) =
VAR top1 =
    "Top 1: "
        & FILTER ( VALUES ( tblCHANNEL[PLACE ID] ), [store rank] = 1 )
        & ", "
        & UNICHAR ( 10 )
VAR top2 =
    "Top 2: "
        & FILTER ( VALUES ( tblCHANNEL[PLACE ID] ), [store rank] = 2 )
        & ", "
        & UNICHAR ( 10 )
VAR top3 =
    "Top 3: "
        & FILTER ( VALUES ( tblCHANNEL[PLACE ID] ), [store rank] = 1 )
RETURN
    top1 & top2
        & top3

I added UNICHAR(10) just in case you want to show them seperated by line breaks on a matrix (you need to turn on word wrap for value).

 

And here's one more measure if you want to show the total value of those top 3 stores:

sum of units (top 3) = 
CALCULATE (
    [sum of units],
    FILTER ( ALL ( tblCHANNEL[PLACE ID] ), [store rank] <= 3 )
)

 

The tooltip measures shoud look like this:

TOP3.png

Please don't forget to kudos or accept this post as solution if you find this helpful. 🙂










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

hi @MarkCBB,

 

I'm not sure which among the fields in your dataset pertains to the store so I just assumed it is PLACE ID.

 

I created the following measures:

sum of units = 
SUM ( 'FACT'[UNITS] )
store rank =
RANKX ( ALL ( tblCHANNEL[PLACE ID] ), [sum of units] )

I am not sure how you want to displace your top 3 in the hover so I just created two top3 measures to be used as tooltips:

top 3 =
CALCULATE (
    CONCATENATEX (
        VALUES ( tblCHANNEL[PLACE ID] ),
        tblCHANNEL[PLACE ID],
        ", " & UNICHAR ( 10 )
    ),
    FILTER ( ALL ( tblCHANNEL[PLACE ID] ), [store rank] <= 3 )
)
Top 3 (w/ order) =
VAR top1 =
    "Top 1: "
        & FILTER ( VALUES ( tblCHANNEL[PLACE ID] ), [store rank] = 1 )
        & ", "
        & UNICHAR ( 10 )
VAR top2 =
    "Top 2: "
        & FILTER ( VALUES ( tblCHANNEL[PLACE ID] ), [store rank] = 2 )
        & ", "
        & UNICHAR ( 10 )
VAR top3 =
    "Top 3: "
        & FILTER ( VALUES ( tblCHANNEL[PLACE ID] ), [store rank] = 1 )
RETURN
    top1 & top2
        & top3

I added UNICHAR(10) just in case you want to show them seperated by line breaks on a matrix (you need to turn on word wrap for value).

 

And here's one more measure if you want to show the total value of those top 3 stores:

sum of units (top 3) = 
CALCULATE (
    [sum of units],
    FILTER ( ALL ( tblCHANNEL[PLACE ID] ), [store rank] <= 3 )
)

 

The tooltip measures shoud look like this:

TOP3.png

Please don't forget to kudos or accept this post as solution if you find this helpful. 🙂










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian that is exactly what I was looking for, thank you for he help. 

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.