Goodnight! I'm trying to use the first_value metri...
# gd-beginners
Goodnight! I'm trying to use the first_value metric, but it's not working. Could anyone help me, or is there another way?
Hi Tomas, The FIRST_VALUE function is only available for our GoodData Cloud product. However, from your screenshot I can see that you’re actually working with our GoodData Platform product. So this is why you’re running into this issue
Are there any metrics similar to what I can use on any good data platform? I want it to only return the last purchase price of the period that the user entered in the dashboard filter.
You can try to use WHERE filter. Example
Copy code
SELECT SUM(SELECT SUM(fact) BY Date(Date) WHERE Date(Date) = (SELECT MIN(SELECT Date (Date) by Records of FactDataset) BY ALL Date(Date)))
Records of FactDataset
is connection point/primary key defined in a dataset where you want to find the minimum date. You can find attribute Records of … in attribute section of metric editor if such connection point is not defined in LDM (GD platform creates this surrogate key attribute in this case automatically). BY ALL Date(Date) tells that there will be only one minimum date used for all displayed values of the metric and it should be filtered by the dashboard/insight filter. In case you slice the metric by e.g. Month it would calculate minimum for each month without the BY ALL Date(Date) clause.