Outer CurrentValue access

While aliasing and naming would work better from a formal / coding perspective, I do agree with @Paul_Danyliuk that the coloring is already a convention for competing variables so why not re-use it?

Second this.

Coloring is great to identify the scope, event though itā€™s currently broken with nested functions. But I assume that would be fixed.

Just to throw in another idea, in addition to coloring, you could think of appending the formula name to it, e.g. ....FormulaMap(...Filter(currentValueFilter = currentValueFormulaMap))

I also agree this is the best solution. However, one way that it might lead to frustration is in copy-pastingā€¦ ideally the level of [currentvalue] would be kept when copy-pasting formulae.

Copy-pasting doesnā€™t work reliably anyways. I think itā€™d be a fair tradeoff.

BTW for the record, hereā€™s a workaround solution I documented elsewhere. Past due it belongs in this topic:

2 Likes

I want to bump this. Just came up for me. I am trying to emulate the output of a Pie Chart, which does this type of thing as part of its default function ā€¦ I want to be able to get an array of all the ā€˜pie percentsā€™.

+1 to Option 1 @shishir

I too am struggling with the need of being able to do FormulaMap(SomeOtherThing.filter(OUTER_CURRENT_VALUE_NEEDED_HERE))

2 Likes

P.S. Re copy-pasting. I think internally in Coda references in formulas are copy-pasted by their full $$[] descriptors, not just the names. And itā€™s just the names when you paste it outside of Coda. My point is, correct CurrentValues may actually stay preserved when copying formulas within Coda.

More about the $$[] operator:

Sorry if Iā€™m hijacking this thread, but maybe thereā€™s a way here I havenā€™t thought of

Where Iā€™ve hardcoded ā€œLinnĆ©aā€, Iā€™d like to use the CurrentValue from the FormulaMap. Is there a way? :slight_smile:

Edit: It wasnā€™t clear in the screenshot, but there can be multiple assignments (and members working) on any given day

My 2 cents on this topic, while having multiple CurrentValue's in this list and highlighting the matching scope with coloring/bold is a nice UX consistent with the current webapp, I believe that an explicit solution is required - certainly at the server API level.

So why not just focus on that first, and roll it out to the UI level as well as a first pass?

So something like :CurrentValue or some other ā€œescapingā€ character (like ... for file systems) to refer to the outer scope(s), as mentioned earlier as a possible solution.

I donā€™t see how to get around the need for explicit syntax - the other solutions are just syntactic/visual sugar to layer on top of this.

2 Likes

Can you please share the doc here or with just me actinarium@gmail.com? I think thereā€™s a way around this.

E.g. if you pull in all assignments for a user, you can rewrite your FormulaMap as:

Members.FormulaMap(List(
  CurrentValue.Name,
  CurrentValue.Assignments.Filter(Date = thisRow.Date).Load.Sum()
))
1 Like

I think you might be on to something, we just have to filter by task start and end date instead. I thinkā€¦

Look at Workload Lab section:

Iā€™ll look a bit later ā€” going to be super busy rn.

1 Like

Not sure whatā€™s happening here, why canā€™t I access the Assignments columns after the Filter() call?

thisRow.Members.FormulaMap(
  List(
    CurrentValue.Name,
    CurrentValue.Assignments.Filter(
      AND(
        Start<=thisRow.Date,
        End>=thisRow.Date
      )
    )
  )
)

edit: Itā€™s as if Filter() returns Members.Assignments.[Project task]ā€¦

@Stefan_Singer

Itā€™s unclear to me exactly what youā€™re after. But hereā€™s one approach that might give you some ideas.

1 Like

Hey, @Ander, thanks for giving this a shot! Interesting with how you use Sequence and Nth, I did not know one could construct loops like that. Your approach is close to what I want, I want the sum of load per assignment, per user. As in: Stefan: 125%, Pontus: 50% etc. Youā€™re close but I donā€™t get how to modify your column 8 to give that result.

Using Sequence and Nth, I managed to solve it :slight_smile:

Sequence(1, thisRow.Members.Count()).FormulaMap(
  List(thisRow.Members.Nth(CurrentValue),
  thisRow.Members.Nth(CurrentValue).Assignments.Filter(
      AND(Start<=thisRow.Date,End>=thisRow.Date)
    ).Load.Sum()
  )
) 

Thanks @Ander for giving me a way to the solution!

2 Likes

Eh, hey @Ander, youā€™ve modified your document afterwards, right? Since I can now see what I was going for in it? :smiley:

1 Like

@Stefan_Singer

Yes, I cleaned it up for future reference. Nice work solving that. I learned a new technique, thanks!

1 Like

But was the solution (The bulleted list in Member Load) there when you first shared it? Did I miss it? Shame on me in that case!

No no, it came after.

1 Like