# KPI Visual Calculation Help

**URL:** <https://community.amazonquick.com/t/kpi-visual-calculation-help/36559>\
**Category:** Q&A\
**Tags:** analysis, data-source, visuals, filters, calculations, Business-Intelligence-Engineer, quick-sight\
**Created:** [October 4, 2024, 5:41pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559 "2024-10-04T17:41:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellosai321](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hellosai321](https://community.amazonquick.com/u/hellosai321)\
**Post date:** [October 4, 2024, 5:42pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/1 "2024-10-04T17:42:00Z")

</div>

I have a program, and some programs have subprograms. I need to build a calculation that adjusts the KPI visual numbers accordingly. For example, the program “Del” has two subprograms, “Task1” and “Task2,” with a total budget of 1,264,000. When I select the program “Del,” the KPI should display 1,264,000. If I filter by subprogram and select “Task1,” it should display 1,234,000.

I was able to build a calculation for a table using this formula:

**sumOver(max(budget), [subprogram, program], POST\_AGG\_FILTER)**

However, this isn’t working for KPI visuals. Could you help me adjust this calculation for KPI visuals?  
 ![qwes](https://d1wl4jav5dp96l.cloudfront.net/original/3X/8/e/8eb90bb1bd9e0cae38d27944e5f5cdcfd1fc66fd.png)

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [October 4, 2024, 7:43pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/2 "2024-10-04T19:43:46Z")

</div>

Hi @hellosai321,  
What result are you getting currently on your KPI when utilizing the calculated field that you tried to build?

Are you using parameter controls setup for your program and subprogram?

---

<div class="post-metadata">

**Author:** ![Pradeep\_Subramanian](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Pradeep\_Subramanian](https://community.amazonquick.com/u/Pradeep_Subramanian)\
**Post date:** [October 6, 2024, 5:14pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/3 "2024-10-06T17:14:06Z")

</div>

Hi @hellosai321 ,

Can you provide us with a screenshot? does it show any error? or the values are not matching?

Thanks,  
Pradeep S

---

<div class="post-metadata">

**Author:** ![hellosai321](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hellosai321](https://community.amazonquick.com/u/hellosai321)\
**Post date:** [October 6, 2024, 5:26pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/4 "2024-10-06T17:26:34Z")

</div>

Hi Brett,

Yes, my controls are parameterized.

While using same calculations for KPI it shows syntax error as program and subprogram are not adding in field values…

---

<div class="post-metadata">

**Author:** ![prantika\_sinha](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/prantika_sinha/32/21878_2.png) [@prantika\_sinha](https://community.amazonquick.com/u/prantika_sinha)\
**Post date:** [October 6, 2024, 8:58pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/5 "2024-10-06T20:58:42Z")

</div>

Hi @hellosai321 ,

Since you are using level aware calculation, the kpi visual must be looking for calculation reference and throwing similar error. One workaround to this is creating a pivot table with all the related fields and then hiding these fields. Also, this workaround has a limitation of not being able to increase font size though. If you can share sample data in the Arena can try helping with a sample workaround.

However, I am curious to know whether the data granularity is different in the dataset. As I see you are using a level aware calculation with max at subprogram level, are there multiple records for each program and sub-program tuple? If not we may not need this level aware calculation.

Hope this helps.

Thanks,  
Prantika

---

<div class="post-metadata">

**Author:** ![hellosai321](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hellosai321](https://community.amazonquick.com/u/hellosai321)\
**Post date:** [October 6, 2024, 9:49pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/6 "2024-10-06T21:49:08Z")

</div>

> [@hellosai321](#):
>
> sumOver(max(budget), [subprogram, program], POST\_AGG\_FILTER)

Hi @prantika_sinha ,

Thank you for your response. I’ve attached a sample screenshot below that shows the data where I was able to generate the desired output in a pivot table, displaying the unique budget for each program and its subprogram using the “Test” field. However, when I try to use the “Test” field in the KPI, I encounter an error. I’m unsure how to achieve the same result for the KPI.

![Captureq](https://d1wl4jav5dp96l.cloudfront.net/original/3X/2/a/2a687d263dba902e10157ba04918af31842e7f91.png)  
Actual Data

 ![qs2](https://d1wl4jav5dp96l.cloudfront.net/original/3X/f/e/fe0be1e3241825c8ee6e78e817f63528ce51162a.png)

[Budget Analysis](https://community.amazonquick.com#Arena-dashboardId=8e00d6ef-cdbf-46a4-a1ea-f7c7dd4eba53&authorId=CU-8957)

---

<div class="post-metadata">

**Author:** ![prantika\_sinha](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/prantika_sinha/32/21878_2.png) [@prantika\_sinha](https://community.amazonquick.com/u/prantika_sinha)\
**Post date:** [October 7, 2024, 6:43am UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/7 "2024-10-07T06:43:05Z")

</div>

I modified the kpi visual to a pivot table to get similar KPI visual. But as mentioned earlier, the font size configuration is a challenge here.

However, since the reason to implement level aware calculation was not clear, I also configured another KPI visual with the budget field and same set of filters. Please check out which one suits your use case!

[sample solution - 36559](https://community.amazonquick.com#Arena-dashboardId=9d861d48-fdfb-4a1b-bfb2-1cc5bab07b01&authorId=CU-7605)

---

<div class="post-metadata">

**Author:** ![hellosai321](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hellosai321](https://community.amazonquick.com/u/hellosai321)\
**Post date:** [October 7, 2024, 12:57pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/8 "2024-10-07T12:57:53Z")

</div>

When filtering for the program “con\_one,” the KPI should display the sum of its unique subprogram budgets, which is 810,000. If a specific subprogram of “con\_one” is selected, the KPI should display only the budget for the selected subprogram.

---

<div class="post-metadata">

**Author:** ![prantika\_sinha](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/prantika_sinha/32/21878_2.png) [@prantika\_sinha](https://community.amazonquick.com/u/prantika_sinha)\
**Post date:** [October 7, 2024, 7:59pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/9 "2024-10-07T19:59:22Z")

</div>

Hi @hellosai321 ,

I have republished the analysis. Let me brief what was the miss.  
Since I am using pivot table, I have created a dummy string to pivot the values against and have collapsed all fields and then disabled the ± controls from the pivot.

In the previous version I missed collapsing all row fields, so the number continued to appear in 2 rows.

For the KPI visual, created a RANK of user id based on program - sub program to limit records and filtered users with rank 1. This will not work if user# to prog-subprog mapping has many to one relationship, like same user id reported against the program-sub program tuple.

Let us know if this meets the requirement!

Thanks,  
Prantika

---

<div class="post-metadata">

**Author:** ![hellosai321](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hellosai321](https://community.amazonquick.com/u/hellosai321)\
**Post date:** [October 7, 2024, 8:39pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/10 "2024-10-07T20:39:21Z")

</div>

Hi @prantika_sinha ,

It worked for my current scenario, but what if we have the same resources repeated in other programs? I have a scenario like this. How to build ranking for this as I don’t unique fields in the dataset.

---

<div class="post-metadata">

**Author:** ![prantika\_sinha](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/prantika_sinha/32/21878_2.png) [@prantika\_sinha](https://community.amazonquick.com/u/prantika_sinha)\
**Post date:** [October 7, 2024, 9:18pm UTC](https://community.amazonquick.com/t/kpi-visual-calculation-help/36559/11 "2024-10-07T21:18:12Z")

</div>

The LAC way of calculation and pivot table option will still work for that case.
