Hello, I'm quite new to GoodData and MAQL and jus...
# gd-beginners
k
Hello, I'm quite new to GoodData and MAQL and just wanted to get clarifications on something: Basically, we have 2 tables: • Assessmentsview, that contains fields as Id and Totalriskscore • Passportcountries that has id and Passportcountry and Id fields And they are mapped using 1:N mapping by Id field I would like to create a visualization where I could display average Totalriskscore and group it by Passportcountries. I was able to achieve it in the Postgres db using the following query:
Copy code
SELECT 
    "PassportCountries"."passportCountry",
    AVG("AssessmentsView"."totalRiskScore") AS "average_risk_score"
FROM 
    "PassportCountries"
JOIN 
    "AssessmentsView" ON "PassportCountries"."id" = "AssessmentsView"."id"
GROUP BY 
    "PassportCountries"."passportCountry";
However, for some reason when I create a new metric in GoodData using something like
SELECT AVG({fact/assessmentsview.totalriskscore})
or
SELECT AVG({fact/assessmentsview.totalriskscore}) BY {dataset/passportcountries}
and trying to input this average score metric and relate it to the Passportcountry field, I don't seem to find it there. After I drop in the Average Risk Score metric, the search only allows me to select fields from the same table where the Totalriskscore comes from, like I can create a visualization mapping lastname field to average risk score (which are both in the same table), but I don't seem to be able to map to Passportcountry (a field that comes from that other table) Is there any way to achieve this inside GoodData?
Getting this in the dashboard:
f
Hi Konstantin, I believe the problem lies in how you’ve configured the Relationship between the Datasets. As your screenshot of the relationship shows, you’ve set it up so that you can slice facts from
Passportcountries
by the attributes in
Assessmentsview
, when it should be the other way around. The article I just linked explains how to properly set up the relationships - make sure that the arrow in the Data Model points from
Passportcountries
to
Assessmentsview
and you should be able to build the insight you described (the metric/MAQL is built perfectly, btw 🙂 )
k
@Francisco Antunes just tried it and it worked as expected, thank you! 🙂
🙌 1