Calculation based on time parameter
I have declared CurrYear and CurrMonth to retrive year and month respectively.
Dim CurrTime As String = api.Pov.Time.Name
Dim CurrYear As Integer = TimeDimHelper.GetSubComponentsFromName(CurrTime).Year
Dim CurrMonth As Integer = TimeDimHelper.GetSubComponentNameFromName(currTime).Month
can you help me to retrieve month in CurrMonth?
So, you want to run the calc2 in 2024 only up until 2024M5? Nothing to be calculated beyond 2024m5? in that case:
If CurrYear < 2024 then Calc1 else If CurrYear.Equals(2024) AndAlso CurrMonth <= 5 Then calc2 end if
Hi, in case you are trying to set up a member formula, consider using the built-in functionality to vary the member formula by time (and / or scenario type).
Your pre-2024M5-calculation will be saved under "(Default Time)" and the post-2024M5-calculation will be saved in "2024M5". This will automatically apply the correct formula in the corresponding time periods.
If that is not within your considerations, you can also use these functions instead of using TimeDimHelpers:
Api.Time.GetYearFromId() Api.Time.GetPeriodNumFromId()
If you need more time functions, please try to rely as much as possible on native functions. This is more future proof and easier to maintain and read. You can e.g. also use this to get the POV prior year:
Api.Time.GetYearFromId(Api.Time.GetPriorYearPeriodId())