Use cell value in a DB() statement

Post Reply
dan.stroebel
Posts: 8
Joined: Wed Mar 03, 2010 10:57 am
OLAP Product: TM1
Version: 9.5
Excel Version: 2007
Location: Germany

Use cell value in a DB() statement

Post by dan.stroebel »

Hi,

I want to parametrise a query.
I have a cube stating the years which looks like this:

Code: Select all

(Admin_Timescale cube)

              | dummy
--------------+-------
Current Year  | 2010
Next Year     | 2011
So, I want to use the cell Current Year here to determine which year should be used in another cube for calculation.
However, this rule is results in all calculated cells being zero:

Code: Select all

['Next_Year_Plan_Value'] = DB('Strategic_Plan', 'PLAN', DB('Admin_Timescale', 'dummy', 'Current Year'), !Products, !MEASURES);
How can I use the other cube's value properly in a DB() statement?

Thanks,
Dan
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Use cell value in a DB() statement

Post by Wim Gielis »

Dan

This seems okay, syntax-wise.

Is the order of the dimensions correctly in your rule? (for both cubes)

You can also put an alias on the time dimensions, saying the alias Current that you put on the correct year. Then you know that the element Current is always valid.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
Alan Kirk
Site Admin
Posts: 6606
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Use cell value in a DB() statement

Post by Alan Kirk »

dan.stroebel wrote:Hi,

I want to parametrise a query.
I have a cube stating the years which looks like this:

Code: Select all

(Admin_Timescale cube)

              | dummy
--------------+-------
Current Year  | 2010
Next Year     | 2011
So, I want to use the cell Current Year here to determine which year should be used in another cube for calculation.
However, this rule is results in all calculated cells being zero:

Code: Select all

['Next_Year_Plan_Value'] = DB('Strategic_Plan', 'PLAN', DB('Admin_Timescale', 'dummy', 'Current Year'), !Products, !MEASURES);
How can I use the other cube's value properly in a DB() statement?

Thanks,
Dan
Is the Current Year value an N type cell or an S type cell? Normally DB would be used to return a numeric value. I may be wrong about this since it's been a long day and I'm in too much need of sleep to test it right now, but I think that if you're using it as you are here, to return an element name of another DB() formula, you'd need it to be returning a string.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
dan.stroebel
Posts: 8
Joined: Wed Mar 03, 2010 10:57 am
OLAP Product: TM1
Version: 9.5
Excel Version: 2007
Location: Germany

Re: Use cell value in a DB() statement

Post by dan.stroebel »

Alan, as always, you're right.
Changing from numeric to string elements fixed the issue.

Thanks,
Dan
Post Reply