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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors