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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Adding date column that grows with numbe of rows

In Power BI, I forecasted Value column using R in the Power Query editor. Then, once I had the forecasted value, I appended it to the original table, which resulted in something like this:

 

Date                             Value              
1/01/20215245
2/01/20213214
3/01/20217458
4/01/202136314
5/01/20215478
 2314
 5478
 63211
 2314
 52336
 1247

 

 

Now I want to add date to the projected values, creating rolling date rows that keeps groowing as the number of rows grows.

 

The final value should seem as follows:

 

Date                             Value              
1/01/20215245
2/01/20213214
3/01/20217458
4/01/202136314
5/01/20215478
6/1/20212314
7/1/20215478
8/1/202163211
9/1/20212314
10/1/202152336
11/1/20211247

 

OR

Add a new date column as follows: 

 

Date                             Value              New   Date          
1/01/202152451/01/2021
2/01/202132142/01/2021
3/01/202174583/01/2021
4/01/2021363144/01/2021
5/01/202154785/01/2021
 23146/1/2021
 54787/1/2021
 632118/1/2021
 23149/1/2021
 5233610/1/2021
 124711/1/2021

 

I did a lot of googling and spent a lot of time on this (almost half a day), but I couldn't find anything useful. And now the Power BI community is my only hope. Any help would be highly appreciated. 🙂

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , First add an index column in power query  https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

Post that in DAX create a new column

 

new date =
var _max = maxx(filter(Table, not(isblank([Date])), [index])
var _maxd = maxx(filter(Table, not(isblank([Date])), [Date])
return
if(not(isblank([Date])), [Date],_maxd + [Index]-_max)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , First add an index column in power query  https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

Post that in DAX create a new column

 

new date =
var _max = maxx(filter(Table, not(isblank([Date])), [index])
var _maxd = maxx(filter(Table, not(isblank([Date])), [Date])
return
if(not(isblank([Date])), [Date],_maxd + [Index]-_max)

Anonymous
Not applicable

OMG, it works, I cannot thank you enough for this. Thank you so much! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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