1

I would like to create summaries for the results of a certain type of task across multiple geographic regions. I currently have the following dummy query:

datatable(env_cloud_location : string, result : string )[
    "East Asia", "Passed",
    "East Asia", "Failed",
    "East Asia", "Error",
    "East US", "Passed",
    "East US", "Error",
    "East US", "Passed",
    "North Europe", "Failed",
    "North Europe", "Error",
    "North Europe", "Error",
]
| summarize 
    eastAsia = countif(env_cloud_location  == "East Asia"),
    eastUS = countif(env_cloud_location  == "East US"),
    northEurope = countif(env_cloud_location == "North Europe")
    by result

Now, I suppose I don't know all the possible values of "env_cloud_location" and there in fact are anywhere from 5 to 12, how can I summarize such that each of these locations, however many there are, gets their own column? Expected output in the format:

result eastAsia eastUS northEurope
Passed 1 2 0
Failed 1 0 1
Error 1 0 2

1 Answer 1

2

Yet another pivot question

datatable(env_cloud_location : string, result : string )[
    "East Asia", "Passed",
    "East Asia", "Failed",
    "East Asia", "Error",
    "East US", "Passed",
    "East US", "Error",
    "East US", "Passed",
    "North Europe", "Failed",
    "North Europe", "Error",
    "North Europe", "Error",
]
| evaluate pivot(env_cloud_location)
result East Asia East US North Europe
Passed 1 2 0
Failed 1 0 1
Error 1 1 2

Fiddle

Sign up to request clarification or add additional context in comments.

1 Comment

I always forget that Pivot tables exist. Thanks for reminding me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.