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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
UksiDuksi
Frequent Visitor

Chart values based on rank

Hello Everyone,

I have following dataset:

ChartRank_DS.JPG

Based on that i want to have 3 charts:

1. Chart #1 is to show items order by sold quantity (pieces)

2. Chart #2 and #3 are to show sales of top 1 sold item by shop (#2 chart) and top 2 sold item by shop (#3)

 

Chart #1 looks like this:
ChartRank chart1.JPG

Chart #2 should look like this:
ChartRank chart2.JPG

I have written following measure:

Rank of Sold Items = 
CALCULATE(
    MAX(Sheet2[Item]),
    FILTER(
        VALUES(Sheet2[Item]),
        RANKX(
            ALL(Sheet2[Item]),
            SUM(Sheet2[Sold pieces])
        ) = 1
    )
)

but this returns Item #4 that is not ranked as #1. I assume that i should use different function then MAX to return name of top 1 ranked item. 
Could you please help change measure so it returns #1 ranked item?

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try the below whether it suits your requirement.

 

Rank of Sold Items =
CALCULATE (
    MAX ( Sheet2[Item] ),
    FILTER (
        VALUES ( Sheet2[Item] ),
        RANKX ( ALL ( Sheet2[Item] ), CALCULATE ( SUM ( Sheet2[Sold pieces] ) ) ) = 1
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try the below whether it suits your requirement.

 

Rank of Sold Items =
CALCULATE (
    MAX ( Sheet2[Item] ),
    FILTER (
        VALUES ( Sheet2[Item] ),
        RANKX ( ALL ( Sheet2[Item] ), CALCULATE ( SUM ( Sheet2[Sold pieces] ) ) ) = 1
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Thank You!

It seems that you did understood because it works. 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.