March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
Can I get only 'Date' values with M code?
I wanna make 'Contract signed date' as a header but data source has unnecessary values on top and it is dynamic.
If it was just null then it would be easy but any code for this?
I'm currently using remove top 2 rows and promoted headers but just in case column header order in row change to row3 or row4 whatsoever.
Hi,
This line of M code should work
=Table.Skip(name of previous step, each not List.Contains(Record.FromList(_), "Contract signed date"))
Hope this helps.
Hi,
Can you help me amend my code?
Cuz List code shows automatic columns which is not for final output.
// Get list of files in SharePoint folder
Documents = Source{[Name="Documents"]}[Content],
// Get list of files in SharePoint folder
#"XXX" = Documents{[Name="XXX"]}[Content],
// Get list of files in SharePoint folder
#"5G SvC_master - GR" = #"XXX"{[Name="5G SvC_master - GR"]}[Content],
#"Removed Other Columns" = Table.SelectColumns(#"5G SvC_master - GR",{"Content", "Name", "Date created"}),
#"Sorted Rows" = Table.Sort(#"Removed Other Columns",{{"Name", Order.Descending}}),
#"Kept First Rows1" = Table.FirstN(#"Sorted Rows",1),
#"Added Custom" = Table.AddColumn(#"Kept First Rows1", "Custom", each Excel.Workbook([Content])),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Name", "Data", "Item", "Kind", "Hidden"}, {"Custom.Name", "Custom.Data", "Custom.Item", "Custom.Kind", "Custom.Hidden"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Custom", each ([Custom.Hidden] = false) and ([Custom.Kind] = "Sheet")),
#"Kept First Rows" = Table.FirstN(#"Filtered Rows",1),
#"Removed Other Columns1" = Table.SelectColumns(#"Kept First Rows",{"Name", "Custom.Name", "Custom.Data", "Date created"}),
// Dynamically get column names and expand
#"Listed Columns" = Table.ColumnNames(#"Removed Other Columns1"[Custom.Data]{0}),
#"Expanded Custom.Data" = Table.ExpandTableColumn(#"Removed Other Columns1", "Custom.Data", #"Listed Columns"),
#"Removed Top Rows" = Table.Skip(#"Expanded Custom.Data",2),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",
{{Table.ColumnNames(#"Promoted Headers"){0}, "Source Name"},
{Table.ColumnNames(#"Promoted Headers"){1}, "Sheet Name"}}),
#"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1, Int64.Type)
in
#"Added Index"
i obviously cannot understand anything by just looking at a screenshot and a piece of code. Anyways, in the code that i shared with you, replace the text within double quotes with column.
pls see the steps
not sure how to apply your code into my steps.
Hi @jeongkim ,
After removed the top 2 rows, instead of promote first row as header, change the data type to date, now you will se errors in your column, just choose remove errors, and manualy give a name for you column:
1-Remove top x rows
Now your data should look like this:
2- Change column type to Date:
Now your Table should look like this, as you can see, there's error in row that contain text:
3- Remove errors:
Your table should look like this:
4- Rename your column as you need.
Hi,
Removing error is good idea.
But what I need is not using removing top 2 rows since it has risk when column header place change to row #1 or row #3.
also column order could change in the future so Im trying to avoid type column name column by column manually.
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
pls read my query before you answer 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
87 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |