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
BennyA
New Member

Missing Dates

I have two date columns, Report Date and Detach Date.  I have some missing Detach Dates (filled with null).  The Report Date column does not have any missing dates.  Is there a function in M Language that will populate the missing dates.  Here is a sample of the data.  The null values need to have the actual detach date (The report date of 7/27/2015 has a Detach Date of 5/21/2020) and the null vlaue should have 5/21/2020 in the cells.

The data set I am working on have several thousand rows of data and I am missing thousands of the detach dates.

Can some one help?

 

Report Date    DetachDate

7/27/2015null
7/27/2015null
7/27/2015null
7/27/2015null
7/27/2015null
7/27/2015null
7/27/2015null
7/27/2015null
7/27/20155/21/2020
7/27/2015null
7/27/2015null
7/27/20155/21/2020
7/27/20155/21/2020
7/27/2015null
7/27/20155/21/2020
7/27/20155/21/2020
7/27/20155/21/2020
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/2018null
4/6/20184/2/2021
4/6/20184/2/2021
1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @BennyA ,

 

Consider using Fill up if the last record of each group [DetachDate] is not the null. 

In other cases, consider grouping [report date] first and then using conditional judgment to replace null.

= Table.Group(YourPreviousStepName, {"Report Date"}, {{"DetachDate", each List.Transform([DetachDate],(x) => if x = null then List.Max([DetachDate]) else x )}})

 

All codes in Adavance Editor.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtc3AiIDQ1MlHaW80pwcpVidQS9oqm9kCGQbGdDEDBJNJ8cgVBkTfTOQhAWyDSNEzETfCBQOhrjFYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Report Date" = _t, DetachDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Report Date", type date}, {"DetachDate", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Report Date"}, {{"DetachDate", each List.Transform([DetachDate],(x) => if x = null then List.Max([DetachDate]) else x )}}),
    #"Expanded DetachDate" = Table.ExpandListColumn(#"Grouped Rows", "DetachDate")
in
    #"Expanded DetachDate"

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @BennyA ,

 

Consider using Fill up if the last record of each group [DetachDate] is not the null. 

In other cases, consider grouping [report date] first and then using conditional judgment to replace null.

= Table.Group(YourPreviousStepName, {"Report Date"}, {{"DetachDate", each List.Transform([DetachDate],(x) => if x = null then List.Max([DetachDate]) else x )}})

 

All codes in Adavance Editor.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtc3AiIDQ1MlHaW80pwcpVidQS9oqm9kCGQbGdDEDBJNJ8cgVBkTfTOQhAWyDSNEzETfCBQOhrjFYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Report Date" = _t, DetachDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Report Date", type date}, {"DetachDate", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Report Date"}, {{"DetachDate", each List.Transform([DetachDate],(x) => if x = null then List.Max([DetachDate]) else x )}}),
    #"Expanded DetachDate" = Table.ExpandListColumn(#"Grouped Rows", "DetachDate")
in
    #"Expanded DetachDate"

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Migasuke
Super User
Super User

Hi @BennyA ,

Your solution is under Fill,
Check here:

Migasuke_0-1685745174096.png

 

 



If my answer was helpful please give me a Kudos or even accept as a Solution.

Let's connect on LinkedIn!

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.

Top Solution Authors