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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
MrMP
Helper III
Helper III

Product ranking

Hi,

 

Is there a way when user selects one product in upper chart for line chart below to plot him what was product rank for each day?

For example, if total of 10 products were sold that day, product was on 2nd place ---> 2/10

 

MrMP_4-1713430815218.png

Dataset is quite simple. Date | Product | Sales

 

Thank you!

 

1 ACCEPTED SOLUTION
v-yaningy-msft
Community Support
Community Support

Hi, @MrMP 

First, thanks for @amitchandak  help. If you have not solve the problem, you can try the following method.

vyaningymsft_0-1713492062993.pngvyaningymsft_1-1713492090393.png

DAX:

Rank = 
RANKX (
    FILTER (
        'Table',
        'Table'[Date] = EARLIER ( 'Table'[Date] )
    ),
    'Table'[Sales],
    ,
    DESC,
    Dense
)
MaxRank = 
VAR _maxRank = CALCULATE(MAX('Table'[Rank]))
RETURN
_maxRank

RANK BY Product =
IF (
    CALCULATE ( SUM ( 'Table'[Rank] ) ) > [MaxRank],
    "Please select one Product",
    [MaxRank]
)

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Not sure of what result you want.  Share data in a format that can be pasted in an MS Excel file.  Show the expected result clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yaningy-msft
Community Support
Community Support

Hi, @MrMP 

First, thanks for @amitchandak  help. If you have not solve the problem, you can try the following method.

vyaningymsft_0-1713492062993.pngvyaningymsft_1-1713492090393.png

DAX:

Rank = 
RANKX (
    FILTER (
        'Table',
        'Table'[Date] = EARLIER ( 'Table'[Date] )
    ),
    'Table'[Sales],
    ,
    DESC,
    Dense
)
MaxRank = 
VAR _maxRank = CALCULATE(MAX('Table'[Rank]))
RETURN
_maxRank

RANK BY Product =
IF (
    CALCULATE ( SUM ( 'Table'[Rank] ) ) > [MaxRank],
    "Please select one Product",
    [MaxRank]
)

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

amitchandak
Super User
Super User

@MrMP , if you create a rank measure it will get distributed based on date in second visual and will give date of filtered product 

 

rankx(allselected(Table[Product]), [Sales measure])

 

or new rank function

 

rank(DENSE,ALLSELECTED(Table[Product], Table[Date]),ORDERBY([Sales],DESC),, partitionBy(Table[Date]) )

 

Power BI - New DAX Function: RANK - How It Differs from RANKX: https://youtu.be/TjGkF44VtDo

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you for help. Bottom chart should be trend over time. With that measure, it gives rank 1 for every calendar date when I select product.

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.