Forum Discussion
There is a whole lot going wrong in your first code fragment. The most glaring of which is that you are attempting to include a member expansion within an intersection. If you want to use GetDataCell(), you will need to loop through the applicable entities getting the desired value for each, or loop through the entities building a combined string of intersections you desire to be issued in a single GetDataCell(). Perhaps it might be safe in your particular situation, but generally it is not safe to assume all the entities share a common currency - you could be summing up what I refer to as unidollars. And for entities not sharing desired currency, then you need to figure out how you want to translate it to the desired entity.
It is not clear whether you are trying to sum the entities before or after the division, or wether the change applies to the numerator, denominator or both, so I won't comment in how you might use a GetDataCells() proof of concept into the existing Calculate(). But be aware that Data Buffers are for a single Data Unit, so performing Calculate() logic on data that spans multiple Data Units requires a bit more, umm, finesse.
So what would you recommend I do to perform that operation in the DataBuffer? I want to calculate a percentage using those values, which is why I'm using a divide, but I haven't found an optimized way to do it.
- rhankey3 days agoContributor III
I would loop through the applicable entities, and either
- perform two GetDataCell()'s/entity, accumulating to a grand total Numerator & Denominator, or
- get a single filtered DataBuffer/entity, from which you could loop through to accumulate to the grand total Numerator & Denominator. This way is a few more lines of code, but reads only a single buffer from the cube/entity, and thus a bit more efficient.
The write back the division of the two grand totals.
Btw, using C#Local is risky. Better to use C#[EntityCurrency]. It's been too long since I used C#[EntityCurrency] to recall what C#Local returns if reading a Data Buffer for a different entity than is currently being computed. Also, if vertical extensibility is being used, and these entities are or could be in different cubes, you will need to specify the Cb# too.
Related Content
- 2 years ago
- 2 years ago
- 2 years ago
- 11 months ago