cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with JS in conversion file

GaJ3
Explorer
367

Hi

I'm trying to load data from an Infocube to BPC. I've a problem with time conversion. I need to add a month to the month in the cube. For instance: if I have 2021012 in the cube, I need to load 2022.JAN in BPC. Indeed this is the only month I having problems with, the rest of the months are working fine with this conversion file

For the XXXX012 data i need someting like this, but of course it isn't working

So I'm trying with some JavaScript code, but I'm not getting proper outcomes.

First I've tried this in the Internal column:

js:%external%.toString.substring(0,4)+1.concat('.JAN') -> I get an error in the package execution

Then I've tried with that code in the Formula column, but it isn't working. I got no errors but BPC is trying to load 2021012 instead of anything that could be understandable to it (e.g. 2021.DEC or 2022.JAN)

Can anyone advice?

Thanks

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

N1kh1l
Active Contributor

Carlos,

Use something like this in the internal column for ????012

js:(parseInt(%external%.toString().slice(0,4))+1).toString()+'.JAN'

Regards

Nikhil

Answers (2)

Answers (2)

former_member186338
Active Contributor

Incorrect JS syntax 🙂

Try:

(Number(%external%.toString().substring(0,4))+1).toString()+'.JAN'

And always test your JS in the online editor like:

https://js.do/

or other

GaJ3
Explorer
0 Kudos

Both your code and Nikhil's code have worked fine

former_member186338
Active Contributor
0 Kudos

jesus.pena

Sorry, but my correct answer was first and you accepted the second answer...

Not a good idea, to my mind

GaJ3
Explorer
0 Kudos

Hi Vadim, I received Nikhil's answer first, and it worked, that's why I've accepted his reply. Maybe you've replied at the same time, but I received his answer first. I've tried both, your code and Nikhil's and both has worked fine. Thanks for your help

GaJ3
Explorer
0 Kudos

Thanks Nikhil, it worked with your code!

N1kh1l
Active Contributor
0 Kudos

You can close the thread and mark it as answered.