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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ianallen13D
Frequent Visitor

Top 5 & Bottom 5 both in Matrix Visual

Hello, 

 

I have a matrix visual that is basically showing the following: 

Fields are: 

Status - basically parent category to Task (i.e. Advance, Develop, etc.)

Task - the name of the task what was completed

 

Then I have a column called "# of Completed Tasks" 

 

ianallen13D_0-1715201303745.png  

ianallen13D_1-1715201318165.png

 

I am being asked to provide the top 5 tasks and the bottom 5 tasks.  It's already filtered for top 5, but I didn't know how to do both top 5 and bottom 5 in the same matrix visual.  Has anyone done this before?

So basically what I'm looking for under each status category is something like this...

 

ianallen13D_2-1715201541512.png

 

Anyone have any easy ideas?  

1 ACCEPTED SOLUTION
Uzi2019
Super User
Super User

Hi   

Modify dax as per you need.

Top Bottom = 
VAR __Products = 
FILTER ( 
    ADDCOLUMNS ( 
        SUMMARIZE ( 
            ALLSELECTED ( Products[Product] ), 
            Products[Product] 
        ), 
        "@Sale", [Sales] 
    ), 
    NOT ISBLANK ( [@Sale] ) 
)  
RETURN
CALCULATE ( 
    [Sales],
    KEEPFILTERS ( 
        UNION (
            TOPN ( 5, __Products, [@Sale], ASC ),
            TOPN ( 5, __Products, [@Sale] )
        )
    )
)

 

 

Or refer below videos
https://www.youtube.com/watch?v=mdj2ilk4rGc

 

 

I hope I answered your question!

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

View solution in original post

3 REPLIES 3
Uzi2019
Super User
Super User

Hi   

Modify dax as per you need.

Top Bottom = 
VAR __Products = 
FILTER ( 
    ADDCOLUMNS ( 
        SUMMARIZE ( 
            ALLSELECTED ( Products[Product] ), 
            Products[Product] 
        ), 
        "@Sale", [Sales] 
    ), 
    NOT ISBLANK ( [@Sale] ) 
)  
RETURN
CALCULATE ( 
    [Sales],
    KEEPFILTERS ( 
        UNION (
            TOPN ( 5, __Products, [@Sale], ASC ),
            TOPN ( 5, __Products, [@Sale] )
        )
    )
)

 

 

Or refer below videos
https://www.youtube.com/watch?v=mdj2ilk4rGc

 

 

I hope I answered your question!

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
nandic
Memorable Member
Memorable Member

Create measure like this:

TopBottom =
    IF(
        ISBLANK(CALCULATE(SUM('Table'[Counter]))),
        BLANK(),
        IF(
            RANKX(
                       ALL('Table'[Task]),
                      CALCULATE(SUM('Table'[Counter])), , ASC) <= 5 ||
      RANKX(
                    ALL('Table'[Task]),
                   CALCULATE(SUM('Table'[Counter])), , DESC) <= 5,
            1,
            0
        )
    )

The result is 1 or 0.
1 if task completed # is in top 5 or bottom 5, otherwise it will return 0.

And then just use that measure as visual filter where you will set measure TopBottom is equal to 1 to only show top/bottom 5 tasks.

The key is to use function rankx with asc to get top tasks, desc to get bottom tasks.

In screenshots below i used top/bottom 3. Image on left is raw data, image on the right is where i used measure as a filter.

nandic_0-1715206163163.png

 



Cheers,
Nemanja Andic

Thank you so much!!  Both options are very helpful.  I really appreciate you guys!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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