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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Reference the last non blank value from the sequential period

Hi ,

I want to create a table in Power BI with continous set of data. The problem is the source has some missing time periods.

MonthContacts
5/1/23200
6/1/23230
9/1/23400
10/1/23410
11/1/23420
12/1/23500
1/1/24560

 

What i want is the below:

MonthContacts
5/1/23200
6/1/23230
7/1/23230
8/1/23230
9/1/23400
10/1/23410
11/1/23420
12/1/23500
1/1/24560

 

I created a measure as following:

Contacts 1 = IF(ISBLANK(MAX(Contacts[Contacts])), CALCULATE(MAX(Contacts[Contacts]),PREVIOUSMONTH('CALENDAR'[Date])), MAX(Contacts[Contacts]))

 

But it is giving value for the first non blank period and is populating as following.

MonthContacts
5/1/23200
6/1/23230
7/1/23230
8/1/23 
9/1/23400
10/1/23410
11/1/23420
12/1/23500
1/1/24560
3 REPLIES 3
Anonymous
Not applicable

@ppm1 Can you please modify your suggestion as per the additional column condition?

ppm1
Solution Sage
Solution Sage

You can do it with a measure but you can also do it in your query (to simplify your DAX and enable other analyses too). Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below. It starts with your full list of dates, merges in your first table and then does a fill down on the Contacts column.

 

 

let
    Source = List.Transform({0..8}, each Date.AddMonths(#date(2023,5,1), _)),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Date"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Date", type date}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Date"}, Contacts, {"Month"}, "Contacts", JoinKind.LeftOuter),
    #"Expanded Contacts" = Table.ExpandTableColumn(#"Merged Queries", "Contacts", {"Contacts"}, {"Contacts.1"}),
    #"Sorted Rows" = Table.Sort(#"Expanded Contacts",{{"Date", Order.Ascending}}),
    #"Filled Down" = Table.FillDown(#"Sorted Rows",{"Contacts.1"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Filled Down",{{"Contacts.1", "Contacts"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns1",{{"Contacts", Int64.Type}})
in
    #"Changed Type1"

 

ppm1_1-1686226350266.png

 

 

Pat

Microsoft Employee
Anonymous
Not applicable

What if i have additional column such as following:

MonthCustomerContacts
5/1/23AA200
6/1/23AA230
9/1/23AA400
10/1/23AA410
11/1/23AA420
12/1/23AA500
1/1/24AA560
10/1/23BB50
11/1/23BB60
1/1/24BB90

 

Intended outup is like:

MonthCustomerContacts
5/1/23AA200
6/1/23AA230
7/1/23AA230
8/1/23AA230
9/1/23AA400
10/1/23AA410
11/1/23AA420
12/1/23AA500
1/1/24AA560
10/1/23BB50
11/1/23BB60
12/1/23BB60
1/1/24BB90

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors