JRan Posted June 21 Share Posted June 21 I am trying to add the following formula via Data Lab into an existing asset tree. Formula: $deviceComBad = $c ~= "Fault" $deviceComGood = $c ~= "Normal" $deviceInOperation = $deviceComBad.union($deviceComGood) $PIDataUnknown = $deviceInOperation.inverse() $PIDataUnknownDuration = $PIDataUnknown.setMaximumDuration(40d).aggregate(totalDuration("s"), weeks(Day.Sunday), middleKey(), 0s) (($PIDataUnknownDuration / 7d) * 100).setUnits('%') Asset tree structure: This is my data lab entry that keeps failing: my_tree.insert(name='% Availability Weekly', formula='$deviceComBad = $c ~= "Fault"', $deviceComGood = $c ~= "Normal" $deviceInOperation = $deviceComBad.union($deviceComGood) $PIDataUnknown = $deviceInOperation.inverse() $PIDataUnknownDuration = $PIDataUnknown.setMaximumDuration(40d).aggregate(totalDuration("s"), weeks(Day.Sunday), middleKey(), 0s) (($PIDataUnknownDuration / 7d) * 100).setUnits('%') formula_parameters={'$c': 'ConnectionStatus'}, parent='AST-1101') my_tree.visualize() Link to comment Share on other sites More sharing options...
Seeq Team Solution Dan FR Posted June 25 Seeq Team Solution Share Posted June 25 (edited) Hi JRan, It looks like the issue is with your string quotations in the formula argument, which are only capturing the first line of your formula. Try using syntax for a multiline formula string with triple quotes: my_tree.insert(name='% Availability Weekly', formula='''$deviceComBad = $c ~= "Fault" $deviceComGood = $c ~= "Normal" $deviceInOperation = $deviceComBad.union($deviceComGood) $PIDataUnknown = $deviceInOperation.inverse() $PIDataUnknownDuration = $PIDataUnknown.setMaximumDuration(40d).aggregate(totalDuration("s"), weeks(Day.Sunday), middleKey(), 0s) (($PIDataUnknownDuration / 7d) * 100).setUnits('%')''', formula_parameters={'$c': 'ConnectionStatus'}, parent='AST-1101') my_tree.visualize() Alternatively, it may be cleaner to save your formula string as a variable and then pass this variable into my_tree.insert() Edited July 2 by Dan FR a comma Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now