Question

Based on GoodData's excellent suggestion for implementing Fact tables, I have been able to design a model that meets our client’s requirements for joining different attributes across different tables. The issue I have now is that the model metrics are highly denormalized, with data repeating itself. I am currently trying to figure out a way to dedupe results.

For example, I have two tables—the first is a NAMES table and the second is my fact table:

NAMES

Val2 Name
35 John
36 Bill
37 Sally

FACT

VAL1 VAL2 SCORE COURSEGRADE

1 35 50 90%

2 35 50 80%

3 35 50 60%

4 36 10 75%

5 37 40 95%

What I am trying to do is write a metric in such a way so that we can get an average of SCORE that eliminates the duplicate value. GoodData is excellent in that it can actually give me back the unique results using the COUNT(VARIABLE1,RECORD) metric, but I can’t seem to get the average store to stick when eliminating the breakout information. If I keep all fields (including the VAL2), it shows me everything:

VAL2 SCORE(AVG)

35 50

36 10

37 40

AVG: 33.33

But when I remove VAL2, I suddenly lose the "uniqueness" of the record.

SCORE(AVG)

40

What I want is the score of 33.33 we got above.

I’ve tried using a BY statement in my SELECT AVG(SCORE), but this doesn’t seem to work. It’s almost like I need some kind of DISTINCT clause. Any thoughts on how to get that rollup value shown in my first example above?

Was it helpful?

Solution

Happy to help here. I would try the following:

  • Create an intermediate metric (let's call it Score by Employee):

    SELECT MIN( SCORE ) BY ID ALL IN ALL OTHER DIMENSIONS

  • Then, once you have this metric defined you should be able to create a metric for the average score as follows:

    SELECT AVG( Score by Employee )

The reason we create the first metric is to force the table to normalize score around the ID attribute which gets rid of duplicates when we use this in the next metric (we could have used MAX or AVG also, it doesn't matter). Hopefully this solves your issue, let me know if it doesn't work and I'll be happy to help out more. Also feel free to check out GoodData's Developer Portal for more information about reporting:

https://developer.gooddata.com/docs/reporting

Best,

JT

OTHER TIPS

you should definitively check "How to build a metric in a metric" presentation, made by Petr Olmer (http://www.slideshare.net/petrolmer/in10-how-to-build-a-metric-in-a-metric).

It can help you to understand it better.

Cheers,

Peter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top