Page 1 of 1
DB inside DB
Posted: Thu Jun 01, 2017 5:16 pm
by Jorge Rachid
Hi,
I am trying to use DB inside DB and I do not have any idea why is not working.
Find attached the screenshots to show the problem.
Can anybody please give me a insight of what could be wrong?
Thanks in advance,
JR
Re: DB inside DB
Posted: Thu Jun 01, 2017 5:30 pm
by Wim Gielis
Your mistake is probably that "Agente - AB e TO" is not the same as "Agente - AB" (see the first nested DB() ). Unless it's an alias.
Re: DB inside DB
Posted: Thu Jun 01, 2017 5:45 pm
by Jorge Rachid
Hi Wim,
It is an alias and I also have tested both DB's and the problem is on the second.
If I use this second DB alone it works. But when it is inside another one I have a problem.
I really don't have idea of what is happening, unfortunately.
Re: DB inside DB
Posted: Thu Jun 01, 2017 5:57 pm
by Wim Gielis
Don't you have an issue with numbers and strings ?
Elements in a dimension are always strings, even when they look like numbers.
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:07 pm
by Jorge Rachid
I am using they like numbers but it should be string? I didn't knew this. I will fix it and try again.
Tks.
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:13 pm
by Jorge Rachid
It doesn't work. I set the metric as string and it was impossible to do the rule because it is a string.
Then I have changed to string the numbers of the source cube and not worked either.
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:15 pm
by tomok
Dimension elements are always strings, regardless of the actual characters used in their names. If you are going to write a DB formula to pull back a value from a cube in order to substitute it for an element name in another part of a formula the value you are pulling back must always be a string.
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:22 pm
by declanr
As the guys are alluding to; you need to wrap an STR function around the DB.
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:23 pm
by tomok
Jorge Rachid wrote:It doesn't work. I set the metric as string and it was impossible to do the rule because it is a string.
Then I have changed to string the numbers of the source cube and not worked either.
All the arguments in a DB formula must be strings. If the value pulled back from this DB:
DB('Volume', !Produtos, !Operacoes, !Itens de Faturam, !Meses Ano, 'Agente -AB')
is not a string then your rule will not work, Time to go back to the drawing board and figure out another strategy.
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:24 pm
by Jorge Rachid
But what happens in the case like mine where the element is calculated? How can I use as string if I have some calculations?
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:41 pm
by tomok
Declanr already gave you the answer. Use the STR function to convert it to a string.
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:49 pm
by Jorge Rachid
I did but still not working.
The DB now it is like this:
['Preço - PA'] = N:
DB('Tabela Preco PA'
, DB('Volume', !Produtos, !Operacoes, !Itens de Faturamento, !Meses Ano, 'Agente - AB')
, STR(DB('Volume', !Produtos, !Operacoes, !Itens de Faturamento, !Meses Ano, 'Taxa Ocupação Ajustada'),3,2)
, '51-100'
, 'Preço');
And the cube where I get the information keep as number.
Is that correct?
Re: DB inside DB
Posted: Thu Jun 01, 2017 6:53 pm
by Wim Gielis
Did you right-click the calculated cell and choose "Trace calculation" ?
Seems obvious to first use the tools available to you to see what is going on.
Re: DB inside DB
Posted: Thu Jun 01, 2017 7:19 pm
by Jorge Rachid
Yes and the only thing that I can see it is zero for this second DB.
Re: DB inside DB
Posted: Thu Jun 01, 2017 7:34 pm
by Wim Gielis
What about the decimal separator ?
Did you create an addition string measure in the / a cube, to only test the STR( DB( )) part ?
If that still gives you the wrong result, please hardcode parts in the formula(s) until you get it working.
After that, bring in the formulas / functions again instead of hardcoded elements.
Re: DB inside DB
Posted: Thu Jun 01, 2017 7:36 pm
by Jorge Rachid
Hi,
Now it is working.
When I use the STR function the number is not 1,95 anymore but 1.95.
So on destination cube I changed the values of dimension and now the DB works.
Sorry and thanks so much!
JR
Re: DB inside DB
Posted: Thu Jun 01, 2017 7:50 pm
by Wim Gielis
That's indeed what I meant with checking the decimal separator.
Glad that it's working now !