Set Dataset Metric in Global Variables

Partner, Registered Posts: 62 Partner

I want to calculate the last day of a column in a dataset and use it dynamically in my SQL recipe. I'm not using Python so I don't know how to set it as a variable. Is there a way to call the metric straight from the SQL recipe? Or send the metrics to global variables after the dataset build?

Answers

  • Dataiker Alumni Posts: 176 ✭✭✭✭✭✭✭✭
    edited July 2024

    Hi @gblack686

    If you're using SQL for your recipe and the statement looks something like this:

    SELECT column_1
           , column_2
           , column_date 
    FROM table

    you can just modify this to be

    SELECT column_1
           , column_2
           , column_date
           , (SELECT MAX(column_date) FROM table) AS column_date_max
    FROM table

    This syntax can sometimes be inefficient if dealing with many such columns on large and non-indexed tables, but it's simple to follow without needing joins.

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.