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
Anonymus_18
Frequent Visitor

Create a new column for missing months with existing data

I have a data in which it'll only be for 4 months i need to reprint that values in the new column.for an example i have data in april'23 i nned to print the data for dec'22 to marc'23 . I have an sample I have provide two table Table 1 and 2. Table one is the i have and table is the desired output.

table 1  
datevalue
Apr-225
Jun-227
Oct-224
Dec-223
Apr-232
Jun-238
Oct-239
Dec-237
table 2 
datevalue
Dec-215
Jan-225
Feb-225
Mar-225
Apr-227
May-227
Jun-224
Jul-224
Aug-224
Sep-224
Oct-223
Nov-223
Dec-222
Jan-232
Feb-232
Mar-232
Apr-238
May-238
Jun-239
Jul-239
Aug-239
Sep-239
Oct-237
Nov-237
Dec-23 
1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

Hello @Anonymus_18 

output : 

Daniel29195_0-1706823818378.png

 

 

steps : 

step  1 : 
adding 2 columns to original table : 

COLUMN1 

Column = 
SELECTCOLUMNS(
OFFSET(
    1, 
    SUMMARIZE(
        date_sol,
        date_sol[date],
        date_sol[value]
    ),
    ORDERBY(date_sol[date], asc)
),
date_sol[value]
)

 

COLUMN2

next ddate = 
var t = 
SELECTCOLUMNS(
OFFSET(
    1, 
    SUMMARIZE(
        date_sol,
        date_sol[date],
        date_sol[value]
    ),
    ORDERBY(date_sol[date], asc)
),
date_sol[date]
)
return
t

 

 

step2 : 

create the table : 

Table_new = 
var datasource = 
FILTER(
SELECTCOLUMNS(
    date_sol,
    "date1",date_sol[date],
    "value", date_sol[value],
    "new_value",date_sol[Column],
    "nextdate", edate(date_sol[next ddate],-1)
),
not isblank([nextdate]) 
)


var added_row = 
DATATABLE(
    "date1" , DATETIME,
    "value", INTEGER,
    "new_value", INTEGER,
    "nextdate", DATETIME,
    {
        {"2021-12-01",0,5, "2022-03-01"}

    }
)


var full_table = 
UNION(
    added_row,
    datasource
)


var res = 
SELECTCOLUMNS(
GENERATE(
    full_table,
    var d1  = [date1]
    var d2 =  [nextdate]
    return
    CALENDAR(d1,d2)
    
    ),

    "newvalue",[new_value],
    "dategenerated",[Date]
)
    
        
       
return 
FILTER(
    res,
    DAY([dategenerated]) = 1
)

 

 

you can modify, the code as per your convenience.

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution !
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

View solution in original post

1 REPLY 1
Daniel29195
Super User
Super User

Hello @Anonymus_18 

output : 

Daniel29195_0-1706823818378.png

 

 

steps : 

step  1 : 
adding 2 columns to original table : 

COLUMN1 

Column = 
SELECTCOLUMNS(
OFFSET(
    1, 
    SUMMARIZE(
        date_sol,
        date_sol[date],
        date_sol[value]
    ),
    ORDERBY(date_sol[date], asc)
),
date_sol[value]
)

 

COLUMN2

next ddate = 
var t = 
SELECTCOLUMNS(
OFFSET(
    1, 
    SUMMARIZE(
        date_sol,
        date_sol[date],
        date_sol[value]
    ),
    ORDERBY(date_sol[date], asc)
),
date_sol[date]
)
return
t

 

 

step2 : 

create the table : 

Table_new = 
var datasource = 
FILTER(
SELECTCOLUMNS(
    date_sol,
    "date1",date_sol[date],
    "value", date_sol[value],
    "new_value",date_sol[Column],
    "nextdate", edate(date_sol[next ddate],-1)
),
not isblank([nextdate]) 
)


var added_row = 
DATATABLE(
    "date1" , DATETIME,
    "value", INTEGER,
    "new_value", INTEGER,
    "nextdate", DATETIME,
    {
        {"2021-12-01",0,5, "2022-03-01"}

    }
)


var full_table = 
UNION(
    added_row,
    datasource
)


var res = 
SELECTCOLUMNS(
GENERATE(
    full_table,
    var d1  = [date1]
    var d2 =  [nextdate]
    return
    CALENDAR(d1,d2)
    
    ),

    "newvalue",[new_value],
    "dategenerated",[Date]
)
    
        
       
return 
FILTER(
    res,
    DAY([dategenerated]) = 1
)

 

 

you can modify, the code as per your convenience.

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution !
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

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.