Forum Discussion

jaws2k's avatar
jaws2k
Frequent Visitor
6 years ago
Solved

Calculated Dynamic Table with multiple columns

Hi,   I am wondering if it is possible to create a dynamic table with multiple columns.   I am looking to generate a table for historical data view ranges, a mix of static values and previous yea...
  • sturlaws's avatar
    6 years ago

    Hi,

     

    I think I got this code to work:

    Historical data =
    VAR _minYear =
        MIN ( vDate[Year] )
    RETURN
        UNION (
            DATATABLE (
                "HistoricalData"; STRING;
                "Sort"; INTEGER;
                {
                    { "1M"; 1 };
                    { "3M"; 2 };
                    { "6M"; 3 };
                    { "9M"; 4 };
                    { "12M"; 5 }
                }
            );
            ADDCOLUMNS ( DISTINCT ( vDate[Year] ); "Sort"; vDate[Year] - _minYear + 6 )
        )

    Cheers,

    S