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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
jobf
Helper II
Helper II

Create a column to rank the dates of the period

Please see the table below:

Field  Period  Date
P1  2324  10/01/2024
P1  2324  10/01/2024
P1  2324  11/02/2024
P1  2425  02/08/2025
P1  2425  01/15/2025
P2  2324  05/05/2024
P2  2324  04/01/2024
P2  2425  01/01/2025
P2  2425  02/10/2025
P2  2425  02/10/2025
P2  2425  01/25/2025


This table shows the dates that a certain product was applied to a certain field. I need a column that shows the application number that occurred on that date of the especific period. It should look like this:

Field  Period  Date  Application
P1  2324  10/01/2024  1
P1  2324  10/01/2024  1
P1  2324  11/02/2024  2
P1  2425  02/08/2025  2
P1  2425  01/15/2025  1
P2  2324  05/05/2024  2
P2  2324  04/01/2024  1
P2  2425  01/01/2025  1
P2  2425  02/10/2025  3
P2  2425  02/10/2025  3
P2  2425  01/25/2025  2


If two lines have the three identical pieces of information, the application number must be the same.

1 ACCEPTED SOLUTION

Hi @jobf ,

Use this DAX:

Application = 
VAR UniqueRank = 
    RANKX(
        FILTER(
            ADDCOLUMNS(
                SUMMARIZE('Table', 'Table'[Field], 'Table'[Period], 'Table'[Date]), 
                "Rank", 'Table'[Date]
            ),
            'Table'[Field] = EARLIER('Table'[Field]) &&
            'Table'[Period] = EARLIER('Table'[Period])
        ),
        'Table'[Date],
        ,
        ASC,
        DENSE
    )

RETURN UniqueRank

 

The output will look like this:

Bibiano_Geraldo_0-1739386051420.png

 

View solution in original post

8 REPLIES 8
Bibiano_Geraldo
Super User
Super User

Hi @jobf ,

To achieve your goal, please, create a new calculated column by this DAX:

Application = 
RANKX(
    FILTER(
        'Table',
        'Table'[Field] = EARLIER('Table'[Field]) &&
        'Table'[Period] = EARLIER('Table'[Period])
    ),
    'Table'[Date],
    ,
    ASC,
    DENSE
)

 

This will return this result:

Bibiano_Geraldo_0-1739381068597.png

 

 

The problem is that sometimes there will be more than one line with the same field, period and date. I needed the code to then put the same application number in both equal lines.

Hi, can you provide a sample data including that scenario and the updated desired result?

 

Hi @jobf ,

But you can try to rank only the unique dates within each Field and Period.:

Application = 
VAR UniqueRank = 
    RANKX(
        FILTER(
            ADDCOLUMNS(
                SUMMARIZE('Table', 'Table'[Field], 'Table'[Period], 'Table'[Date]), 
                "Rank", 'Table'[Date]
            ),
            'Table'[Field] = EARLIER('Table'[Field]) &&
            'Table'[Period] = EARLIER('Table'[Period])
        ),
        'Table'[Date],
        ,
        ASC,
        DENSE
    )

RETURN UniqueRank

 

The output will look like this:

Bibiano_Geraldo_0-1739382649320.png

 

I updated the statement and tables.

Hi @jobf ,

Use this DAX:

Application = 
VAR UniqueRank = 
    RANKX(
        FILTER(
            ADDCOLUMNS(
                SUMMARIZE('Table', 'Table'[Field], 'Table'[Period], 'Table'[Date]), 
                "Rank", 'Table'[Date]
            ),
            'Table'[Field] = EARLIER('Table'[Field]) &&
            'Table'[Period] = EARLIER('Table'[Period])
        ),
        'Table'[Date],
        ,
        ASC,
        DENSE
    )

RETURN UniqueRank

 

The output will look like this:

Bibiano_Geraldo_0-1739386051420.png

 

wini_R
Solution Supplier
Solution Supplier

Hey @jobf,
Please check if this thread helps to solve your issue:
https://community.fabric.microsoft.com/t5/Desktop/TOP-N-by-few-columns/m-p/4406944#M1372085 

wini_R
Solution Supplier
Solution Supplier

Just an alternative solution, if anyone was interested, for adding calculated column using RANK function:

wini_R_0-1739431755417.png

 

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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