Forum Discussion
I need support for write or rectify query
- 1 year ago
yes i got ny correct query and query is here
let// Connect to the ClickHouse databaseSource = ClickHouse.Database("10.1.1.1", 1, null, []),// Navigate to the specific database and tableDB = Source{[Name = "abc", Kind = "Database"]}[Data],JiraIssues = DB{[Name = "jira", Kind = "Table"]}[Data],// Define the mapping of custom field names to friendly namesCustomFieldMap = [customfield_10000 = "Request participants",customfield_10103 = "Account"// Add more mappings here, separated by commas],// Get all column names from the tableColumnNames = Table.ColumnNames(JiraIssues),// Generate a list of {oldName, newName} pairs based on the mappingRenamedColumnsList = List.Transform(ColumnNames, (colName) =>letmatchingKey = List.First(List.Select(Record.FieldNames(CustomFieldMap), each Text.StartsWith(colName, _)), null),newName = if matchingKey <> null thenText.Replace(colName, matchingKey, Record.Field(CustomFieldMap, matchingKey))elsecolNamein{colName, newName}),// Apply the renaming to the tableRenamedTable = Table.RenameColumns(JiraIssues, RenamedColumnsList)inRenamedTable
let
Source = jira_issues,
// Define your custom field mappings here
CustomFieldMap = [
customfield_10000 = "Development",
customfield_10103 = "Original story points"
// Add more mappings as needed
],
// Get all column names
ColumnNames = Table.ColumnNames(Source),
// Generate new column names based on mapping
RenamedColumnsList = List.Transform(ColumnNames, (colName) =>
let
// Try to find a matching customfield key in the column name
matchingKey = List.First(List.Select(Record.FieldNames(CustomFieldMap), each Text.StartsWith(colName, _)), null),
newName = if matchingKey <> null then
Text.Replace(colName, matchingKey, Record.Field(CustomFieldMap, matchingKey))
else
colName
in
{colName, newName}
),
// Apply renaming
RenamedTable = Table.RenameColumns(Source, RenamedColumnsList)
in
When I test with a sample table I cannot replicate a cyclic error. That leads me to believe the error is being generated in your source table.
Here is an alternative method you can try if you wish. If the cyclic error persists you will have to look at your source for the error.
let
Source =
/* Debugging Table
#table(
{"customfield_10000", "customfield_10100", "customfield_10103"},
{
{1,2,3},
{4,5,6}
}
),*/
jira_issues,
// Define your custom field mappings here
CustomFieldMap =
{
{"customfield_10000", "Development"},
{"customfield_10103", "Original story points"}
// Add more mappings as needed
},
RenameColumns =
Table.RenameColumns(
Source,
CustomFieldMap,
MissingField.Ignore
)
in
RenameColumns