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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Maxime_DL
New Member

RANKING ON DATES AND 2 GROUPS

Hello,

 

I'm new to DAX and I'm trying to index dates chronologically, grouped by customers and contracts. This index must respect the filters.

 

Exemple :

I have a dataset with columns CLIENT, CONTRAT and DATE and possible filter on this 3 column

2023-07-29_14h23_12.png

 

 

 

 

 

 

 

 

 

 

 

 

I want to add an index column with exepted result like :

 

2023-07-29_14h22_55.png

 

Can someone help me please ?

 

Regards,

Max

5 REPLIES 5
foodd
Super User
Super User

A date table in Power BI  needs to be unique because it serves as the foundation for date-based calculations and relationships within the data model. When creating a date table, it should consist of unique and continuous dates, typically covering a range of dates without any duplicates or gaps.

I understand the importance of having unique dates but in my case they are not and it is for this reason that I cannot index my dates and that I created this post. This data represents insurance claims. A customer may have a claim on an insurance contract on the same date as another customer or on another contract. Is there a way to circumvent the problem?

Hypothetically, adding your 'Claim number' (and if it is a combination of claim number + indicator + Claimant ID for processing step or change (if necessary) would allow for a unique identifier in the queries).   You will need to test and confirm any relationships and filtering within the model. 

foodd
Super User
Super User

The reply was created from a phone and is untested.  An explanation of the general pattern and a

the sample is below.   You will need to test and adjust the measure where needed.  The key is RANKX

which you can research and find tutorials on for further use.

 

To create an index of dates chronologically, grouped by customers and contracts, while respecting filters, you can use the RANKX function in DAX. The RANKX function allows you to rank values based on a specific expression within a context. In this case, we'll use RANKX to rank the dates for CLIENT and CONTRAT.

 

Index Chronological =
RANKX(
FILTER(ALL('YourTableName'),
NOT(ISBLANK([DATE])) // Apply the necessary filters to exclude blank dates
),
[DATE],
,
ASC,
Dense
)

 

Hello,

 

Thank you for your fast answer but it dont works.

I have an error because the column DATE dont contains unique value.

 

2023-07-29_15h11_24.png

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors