Sergey Aslanov
Sergey Aslanov

Reputation: 683

Azure Application insight Query Merge rows

I have following query:

traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__recordId) or isnotempty(customDimensions.prop__Entity)
| project operation_Id, Entity = customDimensions.prop__Entity, recordName = customDimensions.prop__recordName, recordId = customDimensions.prop__recordId

I get results like these: enter image description here I want to merge rows by operation_id, and get results like these: enter image description here

Upvotes: 0

Views: 875

Answers (2)

Sergey Aslanov
Sergey Aslanov

Reputation: 683

Final query is:

| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__recordId)
| project operation_Id, customDimensions.prop__recordId
| join kind = inner(
traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__Entity)
| project operation_Id,customDimensions.prop__Entity
) on operation_Id
| join kind = inner(
traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__recordName)
| project operation_Id,customDimensions.prop__recordName
) on operation_Id
| project operation_Id, Entity = customDimensions_prop__Entity, recordName = customDimensions_prop__recordName, recordId = customDimensions_prop__recordId

Upvotes: 0

Ivan Glasenberg
Ivan Glasenberg

Reputation: 29950

Please try use join operator, like below:

traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__recordId) 
| project operation_Id, customDimensions.prop__recordId
| join kind = inner(
traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__Entity)
| project operation_Id,customDimensions.prop__Entity,customDimensions.prop__recordName
) on operation_Id
| project-away operation_Id1 //remove the redundant column,note that it's operation_Id1 
| project operation_Id, Entity = customDimensions.prop__Entity, recordName = customDimensions.prop__recordName, recordId = customDimensions.prop__recordId

I did not has the same data, but make some similar data, works fine at my side.

Before merge:

enter image description here

After merge:(and note that use project-away to remove the redundant column which is used as joined key, and it always has number suffix 1 by default)

enter image description here

Upvotes: 1

Related Questions