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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

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
Community Champion
Community Champion

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?

foodd
Community Champion
Community Champion

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
Community Champion
Community Champion

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
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.