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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
pani_victoria
Helper III
Helper III

numbering rows by days of the month

Colleagues, hello!

I have a column with a period and a number of rows with data that equals the number of days in a month.


How can I put days from 1 to 28-31 in a separate column?

PQ cout days.JPG

 

1 ACCEPTED SOLUTION
FarhanJeelani
Super User
Super User

Hi @pani_victoria ,

To achieve this in Power BI, you can create a calculated column that assigns a day number (1 to 28/31) to each row within the month.

Solution in Power BI:

  1. Create a Calculated Column: Use the following DAX formula to create a new column for days:

    DAX

 

DayNumber = 
RANKX(
    FILTER(
        TableName,
        TableName[Period] = EARLIER(TableName[Period])
    ),
    TableName[IndexColumn],
    ,
    ASC
)​

 

  • Replace TableName with your table's name.
  • Replace IndexColumn with a unique column for each row (e.g., row ID or an existing sequential column). If you don’t have one, you can add an Index column in Power Query.
  • Result: This formula will rank rows within each month, creating day numbers 1 to 28/31 in a new column.

Please mark this as solution if it helps. Appreciate Kudos.

View solution in original post

2 REPLIES 2
FarhanJeelani
Super User
Super User

Hi @pani_victoria ,

To achieve this in Power BI, you can create a calculated column that assigns a day number (1 to 28/31) to each row within the month.

Solution in Power BI:

  1. Create a Calculated Column: Use the following DAX formula to create a new column for days:

    DAX

 

DayNumber = 
RANKX(
    FILTER(
        TableName,
        TableName[Period] = EARLIER(TableName[Period])
    ),
    TableName[IndexColumn],
    ,
    ASC
)​

 

  • Replace TableName with your table's name.
  • Replace IndexColumn with a unique column for each row (e.g., row ID or an existing sequential column). If you don’t have one, you can add an Index column in Power Query.
  • Result: This formula will rank rows within each month, creating day numbers 1 to 28/31 in a new column.

Please mark this as solution if it helps. Appreciate Kudos.

Thank you!

It works!)
but not for me

I didn't take into account some input data, because of which this solution doesn't work correctly

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.