Skip to main content

In Lucidchart there are a group of 5 shapes with the Custom Data properties "Type" and "Vol". A readout shape is analyzing the siblings.





  • .siblings.Type = [A B B A]


  • .siblings.Vol = [30 65 45 10]




I would like to:





  1. List the unique Types


  2. Sum the Vol for each Type




The summation can be performed using the Map Filter and Sum functions. For example the hardcoded summation for Type "A" is





  • "All A" = [30 10] = (Map("A"x=>filter(siblingsthis."Type"=x))."Vol"


  • 40 = sum(@."All A")




What I am missing is the ability to generate the unique array of Type to replace the hardcoded ["A""B"] with an expression.





  • "Sorted Vol" = [[3010][6545]] = Map(["A" "B"] x=>filter(siblingsthis."Type"=x))."Vol"


  • [40110] = map(@"Sorted Vol"x=>sum(x))




Has anyone created a formula to do this?

There is a workaround by typecasting the Arrays to an Object with the Zip function. You can then use the Key function to pull the unique elements (akin to a Python dictionary).



  • "Type" = [abba] = siblings."Type"

  • "Vol" = [30654510] = siblings."Vol"

  • "Type Vol Obj" = {"A":[3010]"B":[6545]} = object(zip(@"Type" @"Vol"))

  • "Unique Types" = [ab] = keys(@"Type Vol Obj")


Or compacted:



  • "Type Vol Obj" = [ab] = keys(object(zip(siblings."Type" siblings."Vol")))


The sorted volumes line is then changed to:



  • "Sorted Vol" = [[3010][6545]] = Map(@"Type Vol Obj" x=>filter(siblingsthis."Type"=x))."Vol"


Still the question stands: Is there a cleaner way to do isolate the unique elements of an Array type?


Summation from the Object type avoids the siblings calls.


[40 110] = map(values(@"Type Vol Obj")x=>sum(x))


Hi Jonathon 


Thanks for posting in the Lucidchart Community and sharing your findings! I would recommend checking out our Developer Portal particularly the section dedicated to array formulas to see if any of the formulas available would allow you to achieve what you have in mind. 

If anybody else has tips on formulas that would help Jonathon accomplish what he is trying to do please post below so we can benefit from your knowledge! 


Hi! I’m Micah from Lucid’s community team. 👋 Jumping in here to share about Lucid’s Data Trusted User Group. This group is made up of knowledgeable users who regularly analyze and visualize data in their work. As part of this group, you’ll have the opportunity to connect directly with Lucid’s product team, gain early access to beta features, and share insights about your needs, shaping the future of Lucid’s data solutions 🎉 You can learn more and request to join here. Thanks!

 


Reply