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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Bpark1994
Helper I
Helper I

Need Help with Dax (Display Occurrence Number In Calculated Column)

Hello,

 

Say i have a table with 2 columns and dates out of order like so

 

DateColor
1/1/2017blue
2/5/2017blue
1/24/2017blue
6/25/2017red
9/1/2017red
4/25/2017red
3/26/2017green
2/22/2017green
9/24/2017green
5/26/2017blue

 

I want to be able to create a 3rd calculated column that will give me this...

 

DateColorOccurrence Number
1/1/2017blue1
2/5/2017blue3
1/24/2017blue2
6/25/2017red2
9/1/2017red3
4/25/2017red1
3/26/2017green2
2/22/2017green1
9/24/2017green3
5/26/2017blue4

 

Thanks for the help!

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

the DAX statement to create the calculated column looks like this:

Rank by Date in group color = 
RANKX (
    FILTER (
        'Table2'
        ,'Table2'[Color] = EARLIER ( Table2[Color] )
    )
    ,'Table2'[Date]
    ,
    ,ASC
    ,DENSE
)

If creating a calculated column you have to be aware that calculated value will not change if for example you apply a filter to the rowset, meaning: if you select May (eg by using a slicer), the value of the column will still show 4 for the color blue on the 26th of May 2017. even if there is now just one row.

 

Hopefully this is what you are looking for

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
TomMartens
Super User
Super User

Hey,

 

the DAX statement to create the calculated column looks like this:

Rank by Date in group color = 
RANKX (
    FILTER (
        'Table2'
        ,'Table2'[Color] = EARLIER ( Table2[Color] )
    )
    ,'Table2'[Date]
    ,
    ,ASC
    ,DENSE
)

If creating a calculated column you have to be aware that calculated value will not change if for example you apply a filter to the rowset, meaning: if you select May (eg by using a slicer), the value of the column will still show 4 for the color blue on the 26th of May 2017. even if there is now just one row.

 

Hopefully this is what you are looking for

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Perfect! Thank you Tom!

Tadder
Helper II
Helper II

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

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.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.