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 to check calculation flag. For example: I have 3 dimensions
Account dimension has the following 3 members
Sales
Rebate
Rebate_Flag
UD1 - Product Dimension has many Members
TOTAL_Product Parent member with children(Product_1,Product_2,Product_3,,,,,,Product_N).
No_Product
UD2 - Country of Sale Dimension has one parent member ALL_Country and 2 children members
ALL_Country
USA
Canada
In Hyperion application, I have
Rebate_Flag->USA->No_Product =1
Rebate_Flag->Canada->No_Product =2
I want to calculate Rebate only when Rebate_Flag=1. In OneStream, I want to do
api.Data.Calculation("A#Rebate=A#Sales * 0.10", "UD1#Total_Product.base",true)
But how to I apply the if logic. In Hyperion, I can do
Fix(@Relative("All_Country",0),@Relative("TOTAL_Product",0))
If("Rebate_Flag"->"No_Product"=1) Then
Rebate=Sales*0.10;
End If
But in OneStream, how can I do If("Rebate_Flag"->"No_Product"=1), cross dimension calculation flag check?
Your help is truly appreciated. Thank you in advance.
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}")