Forum Discussion

SimpleLove's avatar
SimpleLove
New Contributor III
6 months ago

How to use if statement to check calculation flag

Dear OneStream Experts: Thank you so much for the great help in the past. I am converting one Hyperion Planning application to OneStream application and would like to know how to use if statement...
  • FredLucas's avatar
    FredLucas
    6 months ago

    If you need the flag to be data (and do bear in mind that in OS Text attributes can be set differently by Period and Scenario Type and could be maintained via a dashboard / business rule if required), then yes, your approach is correct.

    As Henning mentioned for the GetDataCell you'll want to specify the full POV (except for the Data Unit dimensions that if not specified, will use the ones from the Data Unit POV).

    Here's an example:

    Dim flag as DataCell = api.Data.GetDataCell("V#YTD:A#[Staff Costs]:F#None:O#Forms:I#None:U1#IT:U2#None:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None")

    Another thing you might be wondering is, how can I do some debugging to understand what is happening.

    You can use this function to write messages and print the content of your variables to the error log (that you can then check from (system -> Error Log):

    api.LogMessage($"Flag = {flag.CellAmount}; Data Unit POV - Scenario: {api.Pov.Scenario.Name}; Entity: {api.Pov.Entity.Name}; Time: {api.Pov.Time.Name}")