# sourceErrorCode: VISUAL\_CALC\_REFERENCE\_MISSING

**URL:** <https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523>\
**Category:** Q&A\
**Tags:** error, quick-sight\
**Created:** [February 28, 2023, 8:42pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523 "2023-02-28T20:42:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![diego.agrology](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@diego.agrology](https://community.amazonquick.com/u/diego.agrology)\
**Post date:** [February 28, 2023, 8:42pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523/1 "2023-02-28T20:42:50Z")

</div>

Hello everyone,

In the Line Chart, we are having a problem with a calculated metric. The calculated metric has a logic of “ifelse” in which it validates the data of a selector to return one data or another.  
in which it validates the data of a selector to return one data or another.  
The problem is that the data is calculated with a “running sum” and it throws the following error:  
sourceErrorCode: VISUAL\_CALC\_REFERENCE\_MISSING  
sourceType: SPICE  
I tried changing the running sum by a SumOver and there is no error, but we need to calculate the accumulated data (that’s why the RunningSum).  
PS: The selector is also calculated, it takes the value of the control bar.

---

<div class="post-metadata">

**Author:** ![MKuhns01](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@MKuhns01](https://community.amazonquick.com/u/MKuhns01)\
**Post date:** [February 28, 2023, 9:01pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523/2 "2023-02-28T21:01:07Z")

</div>

Can you post your calculated fields and field wells on here?

The Visual Calc Refrence Missing is likely because a field present in the runningSum calculation isn’t added to the visual.

So if you have runningSum( {measure}, [{date} ASC], [{GroupBy}]) you need to include {GroupBy} in the grouping field well

---

<div class="post-metadata">

**Author:** ![diego.agrology](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@diego.agrology](https://community.amazonquick.com/u/diego.agrology)\
**Post date:** [March 1, 2023, 7:15pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523/3 "2023-03-01T19:15:20Z")

</div>

![image_720](https://d1wl4jav5dp96l.cloudfront.net/original/2X/8/8116174c1efe9a4d113d4634cd58be5ae8b27cd9.png)  
I leave more detail about the problem we are having.  
As you can see in the image, we have a control that we use as a selector to display a data and a dimension.  
The process starts when a dimension is selected (1), that selection is passed by parameter to the calculated metric (2) and the dynamic dimension (3).  
The formula of the metric is the following:

ifelse(  
${dynamic dimension}=‘Dimension 1’,runningSum( sum({amount}), [Date ASC], [{1}]), \<— the first line should be resolved  
${dynamic dimension}=‘Dimension 2’,runningSum( sum({amount}), [Date ASC], [{2}]),  
${dynamic dimension}=‘Dimension 3’,runningSum( sum({amount}), [ASC Date], [{3}]),  
0  
)  
Formula detail:  
When I select the “Dimension 1” from control (1), the first line should be resolved, but for some reason when we use the “runningSum” function, the parameter data is lost. This does not happen when we use the function “SumOver” where we check that it does resolve the parameter data.  
As last step in the image (3) we also receive the parameter data from the selector.

---

<div class="post-metadata">

**Author:** ![MKuhns01](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@MKuhns01](https://community.amazonquick.com/u/MKuhns01)\
**Post date:** [March 1, 2023, 7:58pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523/4 "2023-03-01T19:58:27Z")

</div>

The problem is when you are calling {1} in the group by for the runningSum, it would need {1} in the dimension field well of the visual (because runningSum is a table calculation). A New calc field {Groupby} I posted below is a workaround

Try this:

If the values on the control aren’t exact matchs of the values you are trying to group by, create a calculated field like:

{Groupby}:

ifelse(${dynamic dimension} = ‘Dimension 1’, {1},  
${dynamic dimension} = ‘Dimension 2’, {2},  
${dynamic dimension} = ‘Dimension 3’, {3},  
NULL  
)

Add {Groupby} into the “Color” field well

and then use {Groupby} in a formula like:

runningSum(sum({amount}), [Date ASC], [{Groupby}]

And add this formula to the “Value” field of your visual

If the values in the ${dynamic dimension} control are **Exact** matches to the field values, then this alone should work:

runningSum(sum({amount}), [Date ASC], [{$dynamic dimension}]

---

<div class="post-metadata">

**Author:** ![diego.agrology](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@diego.agrology](https://community.amazonquick.com/u/diego.agrology)\
**Post date:** [March 1, 2023, 8:54pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523/5 "2023-03-01T20:54:43Z")

</div>

Thanks for the answer, unfortunately we still have the problem.  
We have the calculated field that you comment. But apparently that solution doesn’t work with the RunningSum function.  
We verify that I change the RunningSum function to SumOver (With the same partition) in that case if it correctly resolves the parameter “Select Dimension” (1) which is the one that groups (Group by)  
We changed the SumOver to RunningSum again and again we have the same problem. So we deduce that the problem is from the RunningSum function.

---

<div class="post-metadata">

**Author:** ![MKuhns01](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@MKuhns01](https://community.amazonquick.com/u/MKuhns01)\
**Post date:** [March 2, 2023, 7:44pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523/6 "2023-03-02T19:44:34Z")

</div>

I remodeled your dataset using simple values for {1} {2} and {3}. Note, the {end} is synonymous with your {Amount}.

I followed the steps I posted above and the visual renders with no problems:

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/c/c177b92558193dc6dbc47cc08c3cbb9d798993f7.png)

![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/5/5c29a7b6daffe2f0c927ba05db49cafef56cdf51.png)

![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/f/f5ae60b0235f5ab574e18f8248aa58f58b486d58.png)

Make sure the Date field, and the calculated group by field I mentioned earlier are the fields being used in the running sum, and in the field wells of the visual. If they are different it will error.

Please make sure your visual resembles the screenshots included. If you are still having issues, please include a screenshot of the calculated fields, field wells, and small portion of your dataset so I can further review.

---

<div class="post-metadata">

**Author:** ![diego.agrology](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@diego.agrology](https://community.amazonquick.com/u/diego.agrology)\
**Post date:** [March 3, 2023, 1:45pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523/7 "2023-03-03T13:45:01Z")

</div>

Thank you very much [MKuhns01](https://community.amazonquick.com/u/MKuhns01), Your answer solved my problem.

---

<div class="post-metadata">

**Author:** ![Kristin](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/kristin/32/2470_2.png) [@Kristin](https://community.amazonquick.com/u/Kristin)\
**Post date:** [March 3, 2023, 4:04pm UTC](https://community.amazonquick.com/t/sourceerrorcode-visual-calc-reference-missing/10523/8 "2023-03-03T16:04:42Z")

</div>

Thanks @MKuhns01! Glad your problem is now solved @diego.agrology!
