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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
abartozzi
Frequent Visitor

Insert an index for a time range

Hi Team, 

 

have this question for you guys regarding a sort of index column. I have this (simplified) dataset for you, where the date range is expanded into different rows in order to reflect the daily duration of each product. 

 

Product nameDuration (days) Duration (night) Service Start (date)Operation day (date)End day (date)
X13210/01/202110/01/202112/01/2021
X13210/01/202111/01/202112/01/2021
X13210/01/202112/01/202112/01/2021
X13220/01/202120/01/202122/01/2021
X13220/01/202121/01/202122/01/2021
X13220/01/202122/01/202122/01/2021

 

what do I need to add to this is a sort of index column that counts the days as follows in this example:

 

Product nameDuration (days) Duration (night) Service Start (date)Operation day (date)End day (date)Day no
X13210/01/202110/01/202112/01/20211
X13210/01/202111/01/202112/01/20212
X13210/01/202112/01/202112/01/20213
X13220/01/202120/01/202122/01/20211
X13220/01/202121/01/202122/01/20212
X13220/01/202122/01/202122/01/20213

 

what do I get is this

 

Product nameDuration (days) Duration (night) Service Start (date)Operation day (date)End day (date)Day no
X13210/01/202110/01/202112/01/20211
X13210/01/202111/01/202112/01/20212
X13210/01/202112/01/202112/01/20213
X13220/01/202120/01/202122/01/20214
X13220/01/202121/01/202122/01/20215
X13220/01/202122/01/202122/01/20216

 

How do i get to the first chart result?

1 ACCEPTED SOLUTION

Hi @PhilipTreacy  and @ryan_mayu 

 

As i needed to do that at query level (the next step was to merge a query with that column) i created a date difference between Operation day and service start +1 as Custom column in order to achieve "day no" column. 

 

The added column with RANKX was another idea I used as at the very beginning!

 

thank you for your hints

View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@abartozzi 

 you can try to create a column

Column = RANKX(FILTER('Table','Table'[Product name]=EARLIER('Table'[Product name])&&'Table'[Service Start (date)]=EARLIER('Table'[Service Start (date)])),'Table'[Operation day (date)],,ASC)

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @PhilipTreacy  and @ryan_mayu 

 

As i needed to do that at query level (the next step was to merge a query with that column) i created a date difference between Operation day and service start +1 as Custom column in order to achieve "day no" column. 

 

The added column with RANKX was another idea I used as at the very beginning!

 

thank you for your hints

PhilipTreacy
Super User
Super User

Hi @abartozzi 

Which column is being indexed?  Service Start or End Day?

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.