Calculated Measures

I’m creating measures in a universe. I’m using @select(formula). I created 2 of these. I plan to divide them into each other to get a percentage. Would I need to put @select with it? Below is what I created:

="@select([Count (Returned)]/[Count (Sent)])"

But that doesn’t give any results. Just displays the formula. But when I use.

=[Count (Returned)]/[Count (Sent)]

I get the percentage I’m seeking (in a report that I’m testing).

So, if I want to create a measure in the universe that calls other measures can I just use the example above?


bull76 (BOB member since 2010-04-08)

Hi,

All measures where a measure is divided by another measure should be defined on a report level. Unless you are using BO XI 3 and you will be using database delegated measures.

[Moderator Note: Moving from WebIntelligence XI forum to Semantic Layer / Universe Designer]


Marek Chladny :slovakia: (BOB member since 2003-11-27)

That’s the version I’m using (I believe). I wanted to set up the division as a measure so that i could use it in a dashboard.


bull76 (BOB member since 2010-04-08)

Anything in quotes is going to display as text. If you want to reference other objects, each has to be referenced individually. The proper format would be:

@select(Class\Object1) / @Select (Class\Object2)

There is no = for a universe object definition.


Dave Rathbun :us: (BOB member since 2002-06-06)

Thanks.

One thing that I just noticed. I created the two measures. Here are examples of them:

Measure 1: is a count on id where return date is >= ‘1/1/2010’

Measure 2: is a count on id where sent date is >= ‘1/1/2010’

Here is the thing. If I were to bring in Measure 1 into the query by itself and then drag it into the report i get the correct number

Same with measure 2.

But if I bring both in together they both return 444. Why would that be?


bull76 (BOB member since 2010-04-08)

You probably have a fan or chasm trap. Either is indicated by inflated measure values. There are tons of topics on the board (and blog posts on the web) related to fan or chasm trap resolutions.


Dave Rathbun :us: (BOB member since 2002-06-06)

Also Additional to Dave’s post, check whether measure1 and measure 2 are coming from same query or belong to two different queries.


gaurav S (BOB member since 2010-04-22)

They’re coming from the same query. Should I use them in different queries?


bull76 (BOB member since 2010-04-08)

I brought them in on different queries and the numbers are right. Why would using different queries work?


bull76 (BOB member since 2010-04-08)

That is another indication that you have a fan or chasm trap in your universe…


Dave Rathbun :us: (BOB member since 2002-06-06)

Hmmm, could be that a date alias is needed.

Are you linking to the same table for returned and sent dates?

If so, create two aliases of it and like one to return date, one to sent date.

This will split out the two meanings of date

Look at the generated SQL! You might have contradicting WHERE clauses defined for your base measures.


Andreas :de: (BOB member since 2002-06-20)

Creating the alias worked. But, when I create a measure to give me the percentage when the returned count is divided by sent count I still get 1. So, basically it’s still having the same issue. But, if I just bring in Return Counts and Sent Counts those numbers are right. It’s just when I create the measure to get a percentage it doesn’t work.


bull76 (BOB member since 2010-04-08)

At this point you’ve described your symptoms but have not provided enough specifics about the structure behind the problem. What does your universe look like? What is the SQL generated for the two measures together? For the measures used individually?


Dave Rathbun :us: (BOB member since 2002-06-06)

Here is the SQL from the Alias table for the Returned Data:

count(Eval_Svc_Reports_Alias_Dont_Use.tid) RESULTS: 522

Here is the SQL for the Sent Data:

count(Eval_Svc_Reports.tid) RESULTS: 956

When I pull those two measures into a report, they work perfect.

But, when I pull the percentage measure (below) in, I get a percentage of 1. That’s because it’s have the initital issure of assigning both measures a count of 444.

b / ( count(Eval_Svc_Reports.tid) )[/b]


bull76 (BOB member since 2010-04-08)

What does the sql code look like for the percentage query? Not the individual object, the entire SQL…


Dave Rathbun :us: (BOB member since 2002-06-06)

Here it is:

SELECT
( count(Eval_Svc_Reports_Alias_Dont_Use.tid) ) / ( count(Eval_Svc_Reports.tid) )
FROM
Eval_Svc_Reports Eval_Svc_Reports_Alias_Dont_Use,
Eval_Svc_Reports,
TRANSFER_ORBIT
WHERE
( TRANSFER_ORBIT.tid=Eval_Svc_Reports.tid )
AND ( TRANSFER_ORBIT.tid=Eval_Svc_Reports_Alias_Dont_Use.tid )


bull76 (BOB member since 2010-04-08)

WHERE
  ( TRANSFER_ORBIT.tid=Eval_Svc_Reports.tid  )
  AND  ( TRANSFER_ORBIT.tid=Eval_Svc_Reports_Alias_Dont_Use.tid  )

There’s your problem. :slight_smile: The number returns 1 because you’re ending up with the same condition going in two different directions. The only possible result is that the value from Eval_Svc_Reports will be identical to the value from Eval_Svc_Reports_Alias_Dont_Use because of the joins.

When you do joins, all of the joins have to be true at the same time. So in this case, the “tid” is the same from the TRANSFER_ORBIT table as well as the other two tables… all at the same time. You mentioned the number 444 earlier. What you’re probably getting is 444 / 444.

Most percentages and averages don’t belong in the universe, they should be done on the report. This is one of the reasons.


Dave Rathbun :us: (BOB member since 2002-06-06)

Ok. Makes total sense. So, am I out of luck in regards to trying to add a percentage to a dashboard?

Is so, can I set some sort of alerter on a bar graph? Something where if the percentage is above 70% make it green. Or if below 70% make it red?


bull76 (BOB member since 2010-04-08)

There still feels like there is something missing. What is supposed to be different about the two counts? In the SQL you posted, there is nothing to distinguish one from the other. But in your earlier posts you said you were getting different numbers.


Dave Rathbun :us: (BOB member since 2002-06-06)