# Issue while displaying value in gauge

**URL:** <https://forum.inductiveautomation.com/t/issue-while-displaying-value-in-gauge/86665>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [March 1, 2024, 9:23am UTC](https://forum.inductiveautomation.com/t/issue-while-displaying-value-in-gauge/86665 "2024-03-01T09:23:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Surya\_Chandra\_Mohan](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Surya\_Chandra\_Mohan](https://forum.inductiveautomation.com/u/Surya_Chandra_Mohan)\
**Post date:** [March 1, 2024, 9:23am UTC](https://forum.inductiveautomation.com/t/issue-while-displaying-value-in-gauge/86665/1 "2024-03-01T09:23:49Z")

</div>

Hello,

I have disabled the label values of gauge component and by using value or maxvalue , I am trying to display the values for gauge but it is not working.  
I have attached the snapshot of the script below -

```auto
	devices_data = sum([durations['ON'] / 60 for address, durations in address_durations.items()])

    # Calculate per minute consumption
	minute_consumption_kwh = hourly_consumption_kwh / 60
	print(minute_consumption_kwh)
	
	duration_data = minute_consumption_kwh * devices_data

    # Format the values for display
	total_kwh_consumed_with_unit = "{:.2f}kwh".format(duration_data)
	print(total_kwh_consumed_with_unit)
	
	# Calculate the difference
	difference_kwh = total_consumption_str - duration_data
	
	# Format the values for display
	difference_with_unit = "{:.2f} kWh".format(difference_kwh)
	print("Difference:", difference_with_unit)
	
	
	#Updating in gauge component
	gauge_day = self.parent.parent.parent.getChild("FlexContainer_1").getChild("FlexContainer_0").getChild("Gauge")
	gauge_week = self.parent.parent.parent.getChild("FlexContainer_1").getChild("FlexContainer_0").getChild("Gauge_0")
	gauge_month = self.parent.parent.parent.getChild("FlexContainer_1").getChild("FlexContainer_0").getChild("Gauge_1")
	
	# Now, depending on the duration_type, update the corresponding gauge
	if duration_type == 1: # Daily
	    gauge_day.props.outerAxis.maxValue = difference_with_unit
	    print("Daily gauge updated:", difference_with_unit)
	elif duration_type == 7: # Weekly
	    gauge_week.props.outerAxis.maxValue = difference_with_unit
	    print("Weekly gauge updated:", difference_with_unit)
	elif duration_type == 30: # Monthly
	    gauge_month.props.outerAxis.maxValue = difference_with_unit
	    print("Monthly gauge updated:", difference_with_unit)

```

It would be really helpful if anyone can please help me out with this issue?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 1, 2024, 9:58am UTC](https://forum.inductiveautomation.com/t/issue-while-displaying-value-in-gauge/86665/2 "2024-03-01T09:58:58Z")

</div>

I don't understand what you are trying to do but I think that all your `parent.parent.parent.getChild().getChild().getChild()` code makes your application very brittle. If you move anything into another container it will break.  
I recommend that you set up some custom properties on the view and write the values to those. Then bind your gauge properties to those.

I would also try to do all this with expression functions rather than a script. You could have custom props for calculated daily, weekly and monthly and switch the gauge bindings based on `duration_type`.

You have one occurrence of `"{:.2f}kwh"`. It should be `"{:.2f}kWh"` (capital W for watt).
