Hello, I'm trying to set a compound primary key, a...
# gd-beginners
m
Hello, I'm trying to set a compound primary key, as referenced in Gooddata University, however, I can't figure out how to do that via the UI (which only has a radio selector to pick one field). What am I missing?
m
Hi Michael, Compound primary keys can be set only in single datasets.
m
What is a single dataset?
No relations?
m
Yes, that’s correct
m
That seems quite limiting.
Well, that IS quite limiting.
m
Sorry to hear that, may I know are you trying to achieve or explain your use case?
j
Basically we want to show Cost Per Conversion on the following graph and get it stacked by
Event Name
, and if you look at the LDM the spend, and converted_total_conversions are on two separate tables, but essentially we only cant about daily FB Ad Spend here, and then divided by the total conversions by
Event Name
These serve as sort of "rates" for us that we can see, but on the DB level spend is only broken down by day so it needs to be on a separate such table. The idea was a composite index here, but I suppose the larger question is if with metrics there is anyway to make the
Cost Per Conversion
Metric work?
t
Hello @Michael DeWulf, based on your description of the UI I suppose you are using GoodData Cloud/CN. Composite keys are not supported there, that’s why the UI offers you only a radio button (as opposed to the University article, which I suppose is made for GoodData Platform). We are currently thinking about how to best support composite keys, including the ability to connect them to different datasets. Although I cannot commit to a concrete delivery date, stay tuned for the following product updates.
m
Hi Jake, if I understand it correctly, you have in your data data: • ad spend per day (not per event name) • converted total conversions per day and event name and you only have it as aggregates, not specific individual conversions. In GoodData you can use the simple metric you have for calculating the average by attributes which both tables share (via references) - in this case the Day and anything in the “_Current Business Config_” dataset. But if you would like to calculate average cost per conversion per day and event name, I am not sure how composite keys would help. If I am reading your model correctly, in the data, there is no information about how Ad Spend is related to Event Name (apart from that they happened on the same day). If for example if the spend for May 12 would be $1000 and there would be “Applicants”, “Bookings” and “Brokers” in the event names for that day, there is no information in the data about how those $1000 should be allocated between those three event names. Should it be divided into 3 equal parts here because there happen to be three event types present for that particular day? That is $333.33 for each event type? Or should the daily spend of $1000 be used for every single one of those event names? Or should some other logic be used to calculate this value? There might be some way how to achieve that it with some more advanced MAQL metric, but since this is not about simple aggregation and needs some business logic, you would need to define how exactly to calculate it.
j
You can use only common dimension attributes if you aggregate facts from two datasets. You cannot break down
sum(FB Ad Spend)
by Event Name. I see two options how to combine such data: 1. use Event Name only to filter Converted) total conversions. For example
select sum(FB Ad Spend) / (select sum(Converted Total Conversions) where Event Name = "Event name 1")
2. Repeat the same value of FB Ad Spend for each event name because Facebook insights daily dataset does not have Event Name detail:
select (select sum(FB Ad Spend) by all Event Name) / sum(Converted Total Conversions)
Please note that I have used simplified MAQL notation. You have to use {fact/fact_identifier} in GD.CN instead of only fact title.