Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi,
my data has header in row 13 but not sure future change such to row 14 or 12.
So any way making KPI ID row always header whereever they placed?
If I use remove top rows then it cannot cover dynamic changes.
Solved! Go to Solution.
Try this one might help you
HeaderRowIndex = List.PositionOf(
Table.Column(Sheet, "Column1"),
"KPI ID"
)
@Anonymous
Add a custom column to identify the row containing "KPI ID".
Filter the table to find the row number of the header.
Use that row number to set the headers dynamically.
Try using below M code
m
let
Source = Excel.CurrentWorkbook(){[Name="YourTableName"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "IsHeader", each if Text.Contains([Column1], "KPI ID") then "Header" else null),
#"Added Index" = Table.AddIndexColumn(#"Added Custom", "Index", 0, 1, Int64.Type),
#"Filtered Rows" = Table.SelectRows(#"Added Index", each ([IsHeader] = "Header")),
HeaderRowIndex = Table.FirstValue(#"Filtered Rows")[Index],
#"Removed Custom" = Table.RemoveColumns(#"Added Index",{"IsHeader", "Index"}),
#"Promoted Headers" = Table.PromoteHeaders(Table.Skip(#"Removed Custom", HeaderRowIndex), [PromoteAllScalars=true])
in
#"Promoted Headers"
Proud to be a Super User! |
|
@Anonymous
Add a custom column to identify the row containing "KPI ID".
Filter the table to find the row number of the header.
Use that row number to set the headers dynamically.
Try using below M code
m
let
Source = Excel.CurrentWorkbook(){[Name="YourTableName"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "IsHeader", each if Text.Contains([Column1], "KPI ID") then "Header" else null),
#"Added Index" = Table.AddIndexColumn(#"Added Custom", "Index", 0, 1, Int64.Type),
#"Filtered Rows" = Table.SelectRows(#"Added Index", each ([IsHeader] = "Header")),
HeaderRowIndex = Table.FirstValue(#"Filtered Rows")[Index],
#"Removed Custom" = Table.RemoveColumns(#"Added Index",{"IsHeader", "Index"}),
#"Promoted Headers" = Table.PromoteHeaders(Table.Skip(#"Removed Custom", HeaderRowIndex), [PromoteAllScalars=true])
in
#"Promoted Headers"
Proud to be a Super User! |
|
Try this one might help you
HeaderRowIndex = List.PositionOf(
Table.Column(Sheet, "Column1"),
"KPI ID"
)
I think it is working thanks
Custom1 = List.PositionOf(
Table.Column(#"Removed Columns", "Custom^Column1"),
"KPI ID"
),
#"Removed Top Rows" = Table.Skip(#"Removed Columns", Custom1),
#"Promoted Headers1" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
I've got this result which saying correct location of header row.
what is the next pls?
@Anonymous If you are confident that at least one of the column headers will never change, you could identify the header row by looking for that column header name to dynamically identify the header row. If you post that sample data as text it will be easier for folks to create a solution for you.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 55 | |
| 35 | |
| 31 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 75 | |
| 72 | |
| 38 | |
| 35 | |
| 25 |