Pivot table calculation against a specific column (controlled by a parameter), instead of table across

I have a pivot table of my data and that has data broken out among rows and columns. I have a value called CPU% that is broken down by test_case(rows) and software_version(columns). I can see the difference in the CPU% from one software_version to the next with a table across calculation; but I want to be able to select a specific software_version via a parameter called reference_version and I’d like all the difference columns to be calculated based on a difference between the particular field and the reference_version field.

I know this has to be possible and I tried playing around with a few examples from the Q&A, but none seemed to quite solve my problem. Maybe someone on here knows the combination of calculated fields I need to achieve this or has solved something like this before.

Any help would be appreciate and thanks in advance.

Hi @Zach6,

You can achieve the desired behavior by adding the following calculated fields to your analysis and pivot table (note that I only split the calculation into two fields for sake of easier readability). In my example, the parameter is called pReferenceVersion.

Add a calculated field called reference_cpu%, which calculates the average reference CPU% value across all rows per test case:


On top of that you can add a second calculated field called difference_to_reference_cpu%, which simply calculates the difference between the CPU% value of each specific version vs its reference CPU% value:


Once added to the pivot table and selecting Average as aggregate option of all values, the result looks as follows:

Did this answer your question? If so, please help the community out by marking this answer as “Solution!”. Thanks!

1 Like

@Thomas I am unable to achieve the results you have with my data. Is there something that is more complex in my example than what you have?

I have a calculated field called reference_avg_value which is:

avgOver(ifelse({host_version}=${ReferenceBuild},value,0),[workload], PRE_AGG)

Then I have another calulated field called diff_with_reference_value which is:

value - {reference_avg_value}

And what I see is:

The only way I can get a calculation like yours is if I add my host_version to the list of partition fields, but then everything is 0 except the reference version. When I change reference_avg_value to this:

avgOver(ifelse({host_version}=${ReferenceBuild},value,0),[workload, {host_version}], PRE_AGG)

I see this data:

Any idea why @Thomas?

Hi @Zach6,
You are right, my first example dataset was a very simplified dataset. I’ve just update the original post to reflect the average calculation that needs to be done for the CPU% calculation when you have multiple rows per test_case and software_version.

I hope this works for your dataset as well. If so, please mark it as a “Solution!”. Thanks!

Finally got some time to try this out and it worked @Thomas. Thanks for your help and I have marked this as Solution!