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
pedroluccas
Frequent Visitor

DYNAMIC INDEX WITH RANKX - SLICERS

Hello!

 

I am working with a data series that relates a "result" (pH, mass, etc) to "sample code" and, in order to calculate my intersect, slope and R² I need an index starting with 1

But when I filter my data, I need that the first sample be reenumerated to 1. Ex: 

- First analysis: Sample 1 to 20 (1 = 1,  2 = 2, 3 = 3, ..., 20 samples)

- Second analysis: Sample 8 to 16 (8 = 1, 9 = 2, 10 = 3, ..., 16 = 9). For this I suppose ALLSELECTED is needed

 

pedroluccas_1-1665086064292.png

I need all the samples ranked by date (ascending), and, if a date repeats for a distinct sample, it's still ranked as a different number (Ex: B2AA/22 and B3AA/22) were analysed the same day, but are different samples, so B2AA/22 = 1 and B3AA/22 = 2)

 

The same way I want select samples of annother product, ex: B1AA/22 - B12AA/22, and, when I change the products the index restart with 1.

 

Is there a way to rank them in a way that every sample has a different number, in ascending order, according to date and that restarts the count with my slicers selection?

 

I tried:

rank =
RANKX(
    ALLSELECTED(Plan1[DATE]),
    CALCULATE(
       MIN(Plan1[DATE])),,ASC,Dense)
-------------------------------------------
But, the rank just repeats the same number...

 

 

I expalin with more details of the statistics on DAX on LINEAR REGRESSION - X-AXIS IN TEXT FORMAT - Microsoft Power BI Community

 

Any ideas?

Thank you very much

 

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @pedroluccas 

Thanks for reaching out to us.

>> Is there a way to rank them in a way that every sample has a different number, in ascending order, according to date and that restarts the count with my slicers selection?

could you share a sample .pbix file that fully covers your question, including the slicers. 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Hi, @v-xiaotang

https://drive.google.com/file/d/1w7qID-TgUBzum14X1WRQXmZn-VYmyc4Z/view?usp=sharing 

I attached a Drive link since I am not able to upload a .pbix file (seems that new users have restrictions)

Thank You
 

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.