Outer CurrentValue access

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:

1 Like

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))

3 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

Ah, I see now, it’s based on my formula above. Do take note, if there’s only one member on a date, the bulleted list will become:

  • Stefan
  • 50%

Because the data then is [Stefan, 50%]

1 Like