Calculation based on time parameter

Manjunathak
New Contributor II

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

Manjunathak_0-1718803800193.png

can you help me to retrieve month in CurrMonth? 

2 ACCEPTED SOLUTIONS

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 

 

 

View solution in original post

Henning
Valued Contributor

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

Henning_0-1718812079525.png

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

 

View solution in original post

5 REPLIES 5

aformenti
Contributor II

Hi @Manjunathak ,

Sure, you can do this by using:

Dim CurrMonth As Integer = api.time.GetSubComponentsFromName(currTime).Month

 

Hi @Manjunathak,

Just re-looking again at your initial code, your mistake was just an spelling issue:

TimeDimHelper.GetSubComponentsFromName(currTime).Month

Hi @aformenti ,

thanks you're right,

can you also help me to break the calculation based on 2024M5?

if it is lease or equal 2024M5 run calc

If currYear < 2024 Then

     Calc

Else If currYear = 2024 & currMonth <=5

    Calc

End If 

End If

 

  the above code is not working for me

 

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 

 

 

Henning
Valued Contributor

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

Henning_0-1718812079525.png

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