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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
deedeedudu
Helper II
Helper II

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
deedeedudu
Helper II
Helper II

@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

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.